@@ -64,13 +64,10 @@ services:
64
64
services :
65
65
app.mysql_lock :
66
66
class : App\Lock\MysqlLock
67
- public : false
68
67
app.postgresql_lock :
69
68
class : App\Lock\PostgresqlLock
70
- public : false
71
69
app.sqlite_lock :
72
70
class : App\Lock\SqliteLock
73
- public : false
74
71
75
72
.. code-block :: xml
76
73
@@ -81,24 +78,31 @@ services:
81
78
https://symfony.com/schema/dic/services/services-1.0.xsd" >
82
79
83
80
<services >
84
- <service id =" app.mysql_lock" public = " false "
81
+ <service id =" app.mysql_lock"
85
82
class =" App\Lock\MysqlLock" />
86
- <service id =" app.postgresql_lock" public = " false "
83
+ <service id =" app.postgresql_lock"
87
84
class =" App\Lock\PostgresqlLock" />
88
- <service id =" app.sqlite_lock" public = " false "
85
+ <service id =" app.sqlite_lock"
89
86
class =" App\Lock\SqliteLock" />
90
87
</services >
91
88
</container >
92
89
93
90
.. code-block :: php
94
91
92
+ // config/services.php
93
+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
94
+
95
95
use App\Lock\MysqlLock;
96
96
use App\Lock\PostgresqlLock;
97
97
use App\Lock\SqliteLock;
98
98
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
+ };
102
106
103
107
Instead of dealing with these three services, your application needs a generic
104
108
``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:
132
136
https://symfony.com/schema/dic/services/services-1.0.xsd" >
133
137
134
138
<services >
135
- <service id =" app.mysql_lock" public = " false "
139
+ <service id =" app.mysql_lock"
136
140
class =" App\Lock\MysqlLock" />
137
- <service id =" app.postgresql_lock" public = " false "
141
+ <service id =" app.postgresql_lock"
138
142
class =" App\Lock\PostgresqlLock" />
139
- <service id =" app.sqlite_lock" public = " false "
143
+ <service id =" app.sqlite_lock"
140
144
class =" App\Lock\SqliteLock" />
141
145
142
146
<service id =" app.lock" >
@@ -147,16 +151,24 @@ the generic ``app.lock`` service can be defined as follows:
147
151
148
152
.. code-block :: php
149
153
154
+ // config/services.php
155
+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
156
+
150
157
use App\Lock\MysqlLock;
151
158
use App\Lock\PostgresqlLock;
152
159
use App\Lock\SqliteLock;
153
160
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);
157
167
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
+ };
160
172
161
173
The ``format `` option defines the expression used to construct the name of the service
162
174
to alias. This expression can use any container parameter (as usual,
0 commit comments