@@ -246,10 +246,13 @@ services:
246
246
services :
247
247
app.mysql_lock :
248
248
class : AppBundle\Lock\MysqlLock
249
+ public : false
249
250
app.postgresql_lock :
250
251
class : AppBundle\Lock\PostgresqlLock
252
+ public : false
251
253
app.sqlite_lock :
252
254
class : AppBundle\Lock\SqliteLock
255
+ public : false
253
256
254
257
.. code-block :: xml
255
258
@@ -259,26 +262,29 @@ services:
259
262
xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" >
260
263
261
264
<services >
262
- <service id =" app.mysql_lock" class =" AppBundle\Lock\MysqlLock" />
263
- <service id =" app.postgresql_lock" class =" AppBundle\Lock\PostgresqlLock" />
264
- <service id =" app.sqlite_lock" class =" AppBundle\Lock\SqliteLock" />
265
+ <service id =" app.mysql_lock" public =" false"
266
+ class =" AppBundle\Lock\MysqlLock" />
267
+ <service id =" app.postgresql_lock" public =" false"
268
+ class =" AppBundle\Lock\PostgresqlLock" />
269
+ <service id =" app.sqlite_lock" public =" false"
270
+ class =" AppBundle\Lock\SqliteLock" />
265
271
</services >
266
272
</container >
267
273
268
274
.. code-block :: php
269
275
270
276
$container
271
- ->register('app.mysql_lock', 'AppBundle\Lock\MysqlLock')
272
- ->register('app.postgresql_lock', 'AppBundle\Lock\PostgresqlLock')
273
- ->register('app.sqlite_lock', 'AppBundle\Lock\SqliteLock')
277
+ ->register('app.mysql_lock', 'AppBundle\Lock\MysqlLock')->setPublic(false)
278
+ ->register('app.postgresql_lock', 'AppBundle\Lock\PostgresqlLock')->setPublic(false)
279
+ ->register('app.sqlite_lock', 'AppBundle\Lock\SqliteLock')->setPublic(false)
274
280
;
275
281
276
282
Instead of dealing with these three services, your application needs a generic
277
- ``app.lock `` service. This service must be an alias to any of the other services.
278
- Thanks to the ``auto_alias `` option, you can automatically create that alias
279
- based on the value of a configuration parameter.
283
+ ``app.lock `` service that will be an alias to one of these services, depending on
284
+ some configuration. Thanks to the ``auto_alias `` option, you can automatically create
285
+ that alias based on the value of a configuration parameter.
280
286
281
- Considering that a configuration parameter called ``database_type `` exists,
287
+ Considering that a configuration parameter called ``database_type `` exists. Then ,
282
288
the generic ``app.lock `` service can be defined as follows:
283
289
284
290
.. configuration-block ::
@@ -287,14 +293,11 @@ the generic ``app.lock`` service can be defined as follows:
287
293
288
294
services :
289
295
app.mysql_lock :
290
- class : AppBundle\Lock\MysqlLock
291
- public : false
296
+ # ...
292
297
app.postgresql_lock :
293
- class : AppBundle\Lock\PostgresqlLock
294
- public : false
298
+ # ...
295
299
app.sqlite_lock :
296
- class : AppBundle\Lock\SqliteLock
297
- public : false
300
+ # ...
298
301
app.lock :
299
302
tags :
300
303
- { name: auto_alias, format: "app.%database_type%_lock" }
@@ -331,8 +334,8 @@ the generic ``app.lock`` service can be defined as follows:
331
334
->addTag('auto_alias', array('format' => 'app.%database_type%_lock'))
332
335
;
333
336
334
- The ``format `` parameter defines the expression used to construct the name of
335
- the service to alias. This expression can use any container parameter (as usual,
337
+ The ``format `` option defines the expression used to construct the name of the service
338
+ to alias. This expression can use any container parameter (as usual,
336
339
wrapping their names with ``% `` characters).
337
340
338
341
.. note ::
0 commit comments