@@ -63,13 +63,10 @@ services:
6363 services :
6464 app.mysql_lock :
6565 class : App\Lock\MysqlLock
66- public : false
6766 app.postgresql_lock :
6867 class : App\Lock\PostgresqlLock
69- public : false
7068 app.sqlite_lock :
7169 class : App\Lock\SqliteLock
72- public : false
7370
7471 .. code-block :: xml
7572
@@ -80,24 +77,31 @@ services:
8077 https://symfony.com/schema/dic/services/services-1.0.xsd" >
8178
8279 <services >
83- <service id =" app.mysql_lock" public = " false "
80+ <service id =" app.mysql_lock"
8481 class =" App\Lock\MysqlLock" />
85- <service id =" app.postgresql_lock" public = " false "
82+ <service id =" app.postgresql_lock"
8683 class =" App\Lock\PostgresqlLock" />
87- <service id =" app.sqlite_lock" public = " false "
84+ <service id =" app.sqlite_lock"
8885 class =" App\Lock\SqliteLock" />
8986 </services >
9087 </container >
9188
9289 .. code-block :: php
9390
91+ // config/services.php
92+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
93+
9494 use App\Lock\MysqlLock;
9595 use App\Lock\PostgresqlLock;
9696 use App\Lock\SqliteLock;
9797
98- $container->register('app.mysql_lock', MysqlLock::class)->setPublic(false);
99- $container->register('app.postgresql_lock', PostgresqlLock::class)->setPublic(false);
100- $container->register('app.sqlite_lock', SqliteLock::class)->setPublic(false);
98+ return function(ContainerConfigurator $configurator) {
99+ $services = $configurator->services();
100+
101+ $services->set('app.mysql_lock', MysqlLock::class);
102+ $services->set('app.postgresql_lock', PostgresqlLock::class);
103+ $services->set('app.sqlite_lock', SqliteLock::class);
104+ };
101105
102106 Instead of dealing with these three services, your application needs a generic
103107``app.lock `` service that will be an alias to one of these services, depending on
@@ -131,11 +135,11 @@ the generic ``app.lock`` service can be defined as follows:
131135 https://symfony.com/schema/dic/services/services-1.0.xsd" >
132136
133137 <services >
134- <service id =" app.mysql_lock" public = " false "
138+ <service id =" app.mysql_lock"
135139 class =" App\Lock\MysqlLock" />
136- <service id =" app.postgresql_lock" public = " false "
140+ <service id =" app.postgresql_lock"
137141 class =" App\Lock\PostgresqlLock" />
138- <service id =" app.sqlite_lock" public = " false "
142+ <service id =" app.sqlite_lock"
139143 class =" App\Lock\SqliteLock" />
140144
141145 <service id =" app.lock" >
@@ -146,16 +150,24 @@ the generic ``app.lock`` service can be defined as follows:
146150
147151 .. code-block :: php
148152
153+ // config/services.php
154+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
155+
149156 use App\Lock\MysqlLock;
150157 use App\Lock\PostgresqlLock;
151158 use App\Lock\SqliteLock;
152159
153- $container->register('app.mysql_lock', MysqlLock::class)->setPublic(false);
154- $container->register('app.postgresql_lock', PostgresqlLock::class)->setPublic(false);
155- $container->register('app.sqlite_lock', SqliteLock::class)->setPublic(false);
160+ return function(ContainerConfigurator $configurator) {
161+ $services = $configurator->services();
162+
163+ $services->set('app.mysql_lock', MysqlLock::class);
164+ $services->set('app.postgresql_lock', PostgresqlLock::class);
165+ $services->set('app.sqlite_lock', SqliteLock::class);
156166
157- $container->register('app.lock')
158- ->addTag('auto_alias', ['format' => 'app.%database_type%_lock']);
167+ $services->set('app.lock')
168+ ->tag('auto_alias', ['format' => 'app.%database_type%_lock'])
169+ ;
170+ };
159171
160172 The ``format `` option defines the expression used to construct the name of the service
161173to alias. This expression can use any container parameter (as usual,
0 commit comments