From 4c50cb07b999c5b58abb673484dd18114dcc8442 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 26 Jun 2015 12:09:09 +0200 Subject: [PATCH] Fixed some errors and added a new note --- reference/dic_tags.rst | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 1a9cd187814..20794ff3319 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -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 @@ -304,12 +307,15 @@ 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"> - - - + + + - + @@ -317,18 +323,25 @@ the generic ``app.lock`` service can be defined as follows: .. 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 ---------------