Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Container.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
11:bfffd8d7479a | 12:7a779792577d |
---|---|
26 * | 26 * |
27 * Services and parameters are simple key/pair stores. | 27 * Services and parameters are simple key/pair stores. |
28 * | 28 * |
29 * Parameter and service keys are case insensitive. | 29 * Parameter and service keys are case insensitive. |
30 * | 30 * |
31 * A service id can contain lowercased letters, digits, underscores, and dots. | |
32 * Underscores are used to separate words, and dots to group services | |
33 * under namespaces: | |
34 * | |
35 * <ul> | |
36 * <li>request</li> | |
37 * <li>mysql_session_storage</li> | |
38 * <li>symfony.mysql_session_storage</li> | |
39 * </ul> | |
40 * | |
41 * A service can also be defined by creating a method named | 31 * A service can also be defined by creating a method named |
42 * getXXXService(), where XXX is the camelized version of the id: | 32 * getXXXService(), where XXX is the camelized version of the id: |
43 * | 33 * |
44 * <ul> | 34 * <ul> |
45 * <li>request -> getRequestService()</li> | 35 * <li>request -> getRequestService()</li> |
64 */ | 54 */ |
65 protected $parameterBag; | 55 protected $parameterBag; |
66 | 56 |
67 protected $services = array(); | 57 protected $services = array(); |
68 protected $methodMap = array(); | 58 protected $methodMap = array(); |
69 protected $privates = array(); | |
70 protected $aliases = array(); | 59 protected $aliases = array(); |
71 protected $loading = array(); | 60 protected $loading = array(); |
61 | |
62 /** | |
63 * @internal | |
64 */ | |
65 protected $privates = array(); | |
72 | 66 |
73 private $underscoreMap = array('_' => '', '.' => '_', '\\' => '_'); | 67 private $underscoreMap = array('_' => '', '.' => '_', '\\' => '_'); |
74 private $envCache = array(); | 68 private $envCache = array(); |
75 | 69 |
76 /** | 70 /** |
198 * @return bool true if the service is defined, false otherwise | 192 * @return bool true if the service is defined, false otherwise |
199 */ | 193 */ |
200 public function has($id) | 194 public function has($id) |
201 { | 195 { |
202 for ($i = 2;;) { | 196 for ($i = 2;;) { |
197 if (isset($this->privates[$id])) { | |
198 @trigger_error(sprintf('Checking for the existence of the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED); | |
199 } | |
200 | |
203 if ('service_container' === $id | 201 if ('service_container' === $id |
204 || isset($this->aliases[$id]) | 202 || isset($this->aliases[$id]) |
205 || isset($this->services[$id]) | 203 || isset($this->services[$id]) |
206 ) { | 204 ) { |
207 return true; | 205 return true; |
208 } | 206 } |
209 | 207 |
210 if (isset($this->privates[$id])) { | |
211 @trigger_error(sprintf('Checking for the existence of the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED); | |
212 } | |
213 | |
214 if (isset($this->methodMap[$id])) { | 208 if (isset($this->methodMap[$id])) { |
215 return true; | 209 return true; |
216 } | 210 } |
217 | 211 |
218 if (--$i && $id !== $lcId = strtolower($id)) { | 212 if (--$i && $id !== $lcId = strtolower($id)) { |
254 // Attempt to retrieve the service by checking first aliases then | 248 // Attempt to retrieve the service by checking first aliases then |
255 // available services. Service IDs are case insensitive, however since | 249 // available services. Service IDs are case insensitive, however since |
256 // this method can be called thousands of times during a request, avoid | 250 // this method can be called thousands of times during a request, avoid |
257 // calling strtolower() unless necessary. | 251 // calling strtolower() unless necessary. |
258 for ($i = 2;;) { | 252 for ($i = 2;;) { |
259 if ('service_container' === $id) { | 253 if (isset($this->privates[$id])) { |
260 return $this; | 254 @trigger_error(sprintf('Requesting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED); |
261 } | 255 } |
262 if (isset($this->aliases[$id])) { | 256 if (isset($this->aliases[$id])) { |
263 $id = $this->aliases[$id]; | 257 $id = $this->aliases[$id]; |
264 } | 258 } |
259 | |
265 // Re-use shared service instance if it exists. | 260 // Re-use shared service instance if it exists. |
266 if (isset($this->services[$id])) { | 261 if (isset($this->services[$id])) { |
267 return $this->services[$id]; | 262 return $this->services[$id]; |
263 } | |
264 if ('service_container' === $id) { | |
265 return $this; | |
268 } | 266 } |
269 | 267 |
270 if (isset($this->loading[$id])) { | 268 if (isset($this->loading[$id])) { |
271 throw new ServiceCircularReferenceException($id, array_keys($this->loading)); | 269 throw new ServiceCircularReferenceException($id, array_keys($this->loading)); |
272 } | 270 } |
298 throw new ServiceNotFoundException($id, null, null, $alternatives); | 296 throw new ServiceNotFoundException($id, null, null, $alternatives); |
299 } | 297 } |
300 | 298 |
301 return; | 299 return; |
302 } | 300 } |
303 if (isset($this->privates[$id])) { | |
304 @trigger_error(sprintf('Requesting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED); | |
305 } | |
306 | 301 |
307 $this->loading[$id] = true; | 302 $this->loading[$id] = true; |
308 | 303 |
309 try { | 304 try { |
310 $service = $this->$method(); | 305 $service = $this->$method(); |
329 */ | 324 */ |
330 public function initialized($id) | 325 public function initialized($id) |
331 { | 326 { |
332 $id = strtolower($id); | 327 $id = strtolower($id); |
333 | 328 |
329 if (isset($this->aliases[$id])) { | |
330 $id = $this->aliases[$id]; | |
331 } | |
332 | |
334 if ('service_container' === $id) { | 333 if ('service_container' === $id) { |
335 return false; | 334 return false; |
336 } | |
337 | |
338 if (isset($this->aliases[$id])) { | |
339 $id = $this->aliases[$id]; | |
340 } | 335 } |
341 | 336 |
342 return isset($this->services[$id]); | 337 return isset($this->services[$id]); |
343 } | 338 } |
344 | 339 |