Skip to content

Commit 4c50cb0

Browse files
committed
Fixed some errors and added a new note
1 parent e24f77e commit 4c50cb0

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

reference/dic_tags.rst

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,16 @@ the generic ``app.lock`` service can be defined as follows:
288288
services:
289289
app.mysql_lock:
290290
class: AppBundle\Lock\MysqlLock
291+
public: false
291292
app.postgresql_lock:
292293
class: AppBundle\Lock\PostgresqlLock
294+
public: false
293295
app.sqlite_lock:
294296
class: AppBundle\Lock\SqliteLock
297+
public: false
295298
app.lock:
296299
tags:
297-
- { name: auto_alias, format: "%database_type%.lock" }
300+
- { name: auto_alias, format: "app.%database_type%.lock" }
298301
299302
.. code-block:: xml
300303
@@ -304,31 +307,41 @@ the generic ``app.lock`` service can be defined as follows:
304307
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
305308
306309
<services>
307-
<service id="app.mysql_lock" class="AppBundle\Lock\MysqlLock" />
308-
<service id="app.postgresql_lock" class="AppBundle\Lock\PostgresqlLock" />
309-
<service id="app.sqlite_lock" class="AppBundle\Lock\SqliteLock" />
310+
<service id="app.mysql_lock" public="false"
311+
class="AppBundle\Lock\MysqlLock" />
312+
<service id="app.postgresql_lock" public="false"
313+
class="AppBundle\Lock\PostgresqlLock" />
314+
<service id="app.sqlite_lock" public="false"
315+
class="AppBundle\Lock\SqliteLock" />
310316
311317
<service id="app.lock">
312-
<tag name="auto_alias" format="%database_type%.lock" />
318+
<tag name="auto_alias" format="app.%database_type%.lock" />
313319
</service>
314320
</services>
315321
</container>
316322
317323
.. code-block:: php
318324
319325
$container
320-
->register('app.mysql_lock', 'AppBundle\Lock\MysqlLock')
321-
->register('app.postgresql_lock', 'AppBundle\Lock\PostgresqlLock')
322-
->register('app.sqlite_lock', 'AppBundle\Lock\SqliteLock')
326+
->register('app.mysql_lock', 'AppBundle\Lock\MysqlLock')->setPublic(false)
327+
->register('app.postgresql_lock', 'AppBundle\Lock\PostgresqlLock')->setPublic(false)
328+
->register('app.sqlite_lock', 'AppBundle\Lock\SqliteLock')->setPublic(false)
323329
324330
->register('app.lock')
325-
->addTag('auto_alias', array('format' => '%database_type%.lock'))
331+
->addTag('auto_alias', array('format' => 'app.%database_type%.lock'))
326332
;
327333
328334
The ``format`` parameter defines the expression used to construct the name of
329335
the service to alias. This expression can use any container parameter (as usual,
330336
wrapping their names with ``%`` characters).
331337

338+
.. note::
339+
340+
When using the ``auto_alias`` tag is not mandatory to define the aliased
341+
services as private. However, doing that (like in the above example) makes
342+
sense most of the times to prevent accessing those services directly instead
343+
of using the generic service.
344+
332345
console.command
333346
---------------
334347

0 commit comments

Comments
 (0)