@@ -93,8 +93,6 @@ public function __construct(ParameterBagInterface $parameterBag = null)
93
93
$ this ->scopeChildren = array ();
94
94
$ this ->scopedServices = array ();
95
95
$ this ->scopeStacks = array ();
96
-
97
- $ this ->set ('service_container ' , $ this );
98
96
}
99
97
100
98
/**
@@ -204,6 +202,12 @@ public function set($id, $service, $scope = self::SCOPE_CONTAINER)
204
202
205
203
$ id = strtolower ($ id );
206
204
205
+ if ('service_container ' === $ id ) {
206
+ // BC: 'service_container' is no longer a self-reference but always
207
+ // $this, so ignore this call.
208
+ // @todo Throw InvalidArgumentException in next major release.
209
+ return ;
210
+ }
207
211
if (self ::SCOPE_CONTAINER !== $ scope ) {
208
212
if (!isset ($ this ->scopedServices [$ scope ])) {
209
213
throw new RuntimeException (sprintf ('You cannot set service "%s" of inactive scope. ' , $ id ));
@@ -240,6 +244,10 @@ public function has($id)
240
244
{
241
245
$ id = strtolower ($ id );
242
246
247
+ if ('service_container ' === $ id ) {
248
+ return true ;
249
+ }
250
+
243
251
return isset ($ this ->services [$ id ])
244
252
|| array_key_exists ($ id , $ this ->services )
245
253
|| isset ($ this ->aliases [$ id ])
@@ -276,6 +284,9 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
276
284
if ($ strtolower ) {
277
285
$ id = strtolower ($ id );
278
286
}
287
+ if ('service_container ' === $ id ) {
288
+ return $ this ;
289
+ }
279
290
if (isset ($ this ->aliases [$ id ])) {
280
291
$ id = $ this ->aliases [$ id ];
281
292
}
@@ -347,6 +358,12 @@ public function initialized($id)
347
358
{
348
359
$ id = strtolower ($ id );
349
360
361
+ if ('service_container ' === $ id ) {
362
+ // BC: 'service_container' was a synthetic service previously.
363
+ // @todo Change to false in next major release.
364
+ return true ;
365
+ }
366
+
350
367
return isset ($ this ->services [$ id ]) || array_key_exists ($ id , $ this ->services );
351
368
}
352
369
@@ -364,6 +381,7 @@ public function getServiceIds()
364
381
$ ids [] = self ::underscore ($ match [1 ]);
365
382
}
366
383
}
384
+ $ ids [] = 'service_container ' ;
367
385
368
386
return array_unique (array_merge ($ ids , array_keys ($ this ->services )));
369
387
}
0 commit comments