@@ -288,13 +288,16 @@ the generic ``app.lock`` service can be defined as follows:
288
288
services :
289
289
app.mysql_lock :
290
290
class : AppBundle\Lock\MysqlLock
291
+ public : false
291
292
app.postgresql_lock :
292
293
class : AppBundle\Lock\PostgresqlLock
294
+ public : false
293
295
app.sqlite_lock :
294
296
class : AppBundle\Lock\SqliteLock
297
+ public : false
295
298
app.lock :
296
299
tags :
297
- - { name: auto_alias, format: "%database_type%.lock" }
300
+ - { name: auto_alias, format: "app. %database_type%.lock" }
298
301
299
302
.. code-block :: xml
300
303
@@ -304,31 +307,41 @@ the generic ``app.lock`` service can be defined as follows:
304
307
xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
305
308
306
309
<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" />
310
316
311
317
<service id =" app.lock" >
312
- <tag name =" auto_alias" format =" %database_type%.lock" />
318
+ <tag name =" auto_alias" format =" app. %database_type%.lock" />
313
319
</service >
314
320
</services >
315
321
</container >
316
322
317
323
.. code-block :: php
318
324
319
325
$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)
323
329
324
330
->register('app.lock')
325
- ->addTag('auto_alias', array('format' => '%database_type%.lock'))
331
+ ->addTag('auto_alias', array('format' => 'app. %database_type%.lock'))
326
332
;
327
333
328
334
The ``format `` parameter defines the expression used to construct the name of
329
335
the service to alias. This expression can use any container parameter (as usual,
330
336
wrapping their names with ``% `` characters).
331
337
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
+
332
345
console.command
333
346
---------------
334
347
0 commit comments