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