@@ -64,13 +64,10 @@ services:
6464 services :
6565 app.mysql_lock :
6666 class : App\Lock\MysqlLock
67- public : false
6867 app.postgresql_lock :
6968 class : App\Lock\PostgresqlLock
70- public : false
7169 app.sqlite_lock :
7270 class : App\Lock\SqliteLock
73- public : false
7471
7572 .. code-block :: xml
7673
@@ -81,24 +78,31 @@ services:
8178 https://symfony.com/schema/dic/services/services-1.0.xsd" >
8279
8380 <services >
84- <service id =" app.mysql_lock" public = " false "
81+ <service id =" app.mysql_lock"
8582 class =" App\Lock\MysqlLock" />
86- <service id =" app.postgresql_lock" public = " false "
83+ <service id =" app.postgresql_lock"
8784 class =" App\Lock\PostgresqlLock" />
88- <service id =" app.sqlite_lock" public = " false "
85+ <service id =" app.sqlite_lock"
8986 class =" App\Lock\SqliteLock" />
9087 </services >
9188 </container >
9289
9390 .. code-block :: php
9491
92+ // config/services.php
93+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
94+
9595 use App\Lock\MysqlLock;
9696 use App\Lock\PostgresqlLock;
9797 use App\Lock\SqliteLock;
9898
99- $container->register('app.mysql_lock', MysqlLock::class)->setPublic(false);
100- $container->register('app.postgresql_lock', PostgresqlLock::class)->setPublic(false);
101- $container->register('app.sqlite_lock', SqliteLock::class)->setPublic(false);
99+ return function(ContainerConfigurator $configurator) {
100+ $services = $configurator->services();
101+
102+ $services->set('app.mysql_lock', MysqlLock::class);
103+ $services->set('app.postgresql_lock', PostgresqlLock::class);
104+ $services->set('app.sqlite_lock', SqliteLock::class);
105+ };
102106
103107 Instead of dealing with these three services, your application needs a generic
104108``app.lock `` service that will be an alias to one of these services, depending on
@@ -132,11 +136,11 @@ the generic ``app.lock`` service can be defined as follows:
132136 https://symfony.com/schema/dic/services/services-1.0.xsd" >
133137
134138 <services >
135- <service id =" app.mysql_lock" public = " false "
139+ <service id =" app.mysql_lock"
136140 class =" App\Lock\MysqlLock" />
137- <service id =" app.postgresql_lock" public = " false "
141+ <service id =" app.postgresql_lock"
138142 class =" App\Lock\PostgresqlLock" />
139- <service id =" app.sqlite_lock" public = " false "
143+ <service id =" app.sqlite_lock"
140144 class =" App\Lock\SqliteLock" />
141145
142146 <service id =" app.lock" >
@@ -147,16 +151,24 @@ the generic ``app.lock`` service can be defined as follows:
147151
148152 .. code-block :: php
149153
154+ // config/services.php
155+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
156+
150157 use App\Lock\MysqlLock;
151158 use App\Lock\PostgresqlLock;
152159 use App\Lock\SqliteLock;
153160
154- $container->register('app.mysql_lock', MysqlLock::class)->setPublic(false);
155- $container->register('app.postgresql_lock', PostgresqlLock::class)->setPublic(false);
156- $container->register('app.sqlite_lock', SqliteLock::class)->setPublic(false);
161+ return function(ContainerConfigurator $configurator) {
162+ $services = $configurator->services();
163+
164+ $services->set('app.mysql_lock', MysqlLock::class);
165+ $services->set('app.postgresql_lock', PostgresqlLock::class);
166+ $services->set('app.sqlite_lock', SqliteLock::class);
157167
158- $container->register('app.lock')
159- ->addTag('auto_alias', ['format' => 'app.%database_type%_lock']);
168+ $services->set('app.lock')
169+ ->tag('auto_alias', ['format' => 'app.%database_type%_lock'])
170+ ;
171+ };
160172
161173 The ``format `` option defines the expression used to construct the name of the service
162174to alias. This expression can use any container parameter (as usual,
0 commit comments