Skip to content

Commit

Permalink
Fixed some errors and added a new note
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Jun 26, 2015
1 parent e24f77e commit 4c50cb0
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions reference/dic_tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,16 @@ the generic ``app.lock`` service can be defined as follows:
services:
app.mysql_lock:
class: AppBundle\Lock\MysqlLock
public: false
app.postgresql_lock:
class: AppBundle\Lock\PostgresqlLock
public: false
app.sqlite_lock:
class: AppBundle\Lock\SqliteLock
public: false
app.lock:
tags:
- { name: auto_alias, format: "%database_type%.lock" }
- { name: auto_alias, format: "app.%database_type%.lock" }
.. code-block:: xml
Expand All @@ -304,31 +307,41 @@ the generic ``app.lock`` service can be defined as follows:
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="app.mysql_lock" class="AppBundle\Lock\MysqlLock" />
<service id="app.postgresql_lock" class="AppBundle\Lock\PostgresqlLock" />
<service id="app.sqlite_lock" class="AppBundle\Lock\SqliteLock" />
<service id="app.mysql_lock" public="false"
class="AppBundle\Lock\MysqlLock" />
<service id="app.postgresql_lock" public="false"
class="AppBundle\Lock\PostgresqlLock" />
<service id="app.sqlite_lock" public="false"
class="AppBundle\Lock\SqliteLock" />
<service id="app.lock">
<tag name="auto_alias" format="%database_type%.lock" />
<tag name="auto_alias" format="app.%database_type%.lock" />
</service>
</services>
</container>
.. code-block:: php
$container
->register('app.mysql_lock', 'AppBundle\Lock\MysqlLock')
->register('app.postgresql_lock', 'AppBundle\Lock\PostgresqlLock')
->register('app.sqlite_lock', 'AppBundle\Lock\SqliteLock')
->register('app.mysql_lock', 'AppBundle\Lock\MysqlLock')->setPublic(false)
->register('app.postgresql_lock', 'AppBundle\Lock\PostgresqlLock')->setPublic(false)
->register('app.sqlite_lock', 'AppBundle\Lock\SqliteLock')->setPublic(false)
->register('app.lock')
->addTag('auto_alias', array('format' => '%database_type%.lock'))
->addTag('auto_alias', array('format' => 'app.%database_type%.lock'))
;
The ``format`` parameter defines the expression used to construct the name of
the service to alias. This expression can use any container parameter (as usual,
wrapping their names with ``%`` characters).

.. note::

When using the ``auto_alias`` tag is not mandatory to define the aliased
services as private. However, doing that (like in the above example) makes
sense most of the times to prevent accessing those services directly instead
of using the generic service.

console.command
---------------

Expand Down

0 comments on commit 4c50cb0

Please sign in to comment.