comparison vendor/symfony/dependency-injection/Loader/YamlFileLoader.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
211 211
212 if (!\is_array($content['services'])) { 212 if (!\is_array($content['services'])) {
213 throw new InvalidArgumentException(sprintf('The "services" key should contain an array in %s. Check your YAML syntax.', $file)); 213 throw new InvalidArgumentException(sprintf('The "services" key should contain an array in %s. Check your YAML syntax.', $file));
214 } 214 }
215 215
216 if (array_key_exists('_instanceof', $content['services'])) { 216 if (\array_key_exists('_instanceof', $content['services'])) {
217 $instanceof = $content['services']['_instanceof']; 217 $instanceof = $content['services']['_instanceof'];
218 unset($content['services']['_instanceof']); 218 unset($content['services']['_instanceof']);
219 219
220 if (!\is_array($instanceof)) { 220 if (!\is_array($instanceof)) {
221 throw new InvalidArgumentException(sprintf('Service "_instanceof" key must be an array, "%s" given in "%s".', \gettype($instanceof), $file)); 221 throw new InvalidArgumentException(sprintf('Service "_instanceof" key must be an array, "%s" given in "%s".', \gettype($instanceof), $file));
248 * 248 *
249 * @throws InvalidArgumentException 249 * @throws InvalidArgumentException
250 */ 250 */
251 private function parseDefaults(array &$content, $file) 251 private function parseDefaults(array &$content, $file)
252 { 252 {
253 if (!array_key_exists('_defaults', $content['services'])) { 253 if (!\array_key_exists('_defaults', $content['services'])) {
254 return []; 254 return [];
255 } 255 }
256 $defaults = $content['services']['_defaults']; 256 $defaults = $content['services']['_defaults'];
257 unset($content['services']['_defaults']); 257 unset($content['services']['_defaults']);
258 258
359 359
360 $this->checkDefinition($id, $service, $file); 360 $this->checkDefinition($id, $service, $file);
361 361
362 if (isset($service['alias'])) { 362 if (isset($service['alias'])) {
363 $this->container->setAlias($id, $alias = new Alias($service['alias'])); 363 $this->container->setAlias($id, $alias = new Alias($service['alias']));
364 if (array_key_exists('public', $service)) { 364 if (\array_key_exists('public', $service)) {
365 $alias->setPublic($service['public']); 365 $alias->setPublic($service['public']);
366 } elseif (isset($defaults['public'])) { 366 } elseif (isset($defaults['public'])) {
367 $alias->setPublic($defaults['public']); 367 $alias->setPublic($defaults['public']);
368 } 368 }
369 369
436 436
437 if (isset($service['abstract'])) { 437 if (isset($service['abstract'])) {
438 $definition->setAbstract($service['abstract']); 438 $definition->setAbstract($service['abstract']);
439 } 439 }
440 440
441 if (array_key_exists('deprecated', $service)) { 441 if (\array_key_exists('deprecated', $service)) {
442 $definition->setDeprecated(true, $service['deprecated']); 442 $definition->setDeprecated(true, $service['deprecated']);
443 } 443 }
444 444
445 if (isset($service['factory'])) { 445 if (isset($service['factory'])) {
446 $definition->setFactory($this->parseCallable($service['factory'], 'factory', $id, $file)); 446 $definition->setFactory($this->parseCallable($service['factory'], 'factory', $id, $file));
569 } elseif ($service['autoconfigure']) { 569 } elseif ($service['autoconfigure']) {
570 throw new InvalidArgumentException(sprintf('The service "%s" cannot have a "parent" and also have "autoconfigure". Try setting "autoconfigure: false" for the service.', $id)); 570 throw new InvalidArgumentException(sprintf('The service "%s" cannot have a "parent" and also have "autoconfigure". Try setting "autoconfigure: false" for the service.', $id));
571 } 571 }
572 } 572 }
573 573
574 if (array_key_exists('namespace', $service) && !array_key_exists('resource', $service)) { 574 if (\array_key_exists('namespace', $service) && !\array_key_exists('resource', $service)) {
575 throw new InvalidArgumentException(sprintf('A "resource" attribute must be set when the "namespace" attribute is set for service "%s" in %s. Check your YAML syntax.', $id, $file)); 575 throw new InvalidArgumentException(sprintf('A "resource" attribute must be set when the "namespace" attribute is set for service "%s" in %s. Check your YAML syntax.', $id, $file));
576 } 576 }
577 577
578 if (array_key_exists('resource', $service)) { 578 if (\array_key_exists('resource', $service)) {
579 if (!\is_string($service['resource'])) { 579 if (!\is_string($service['resource'])) {
580 throw new InvalidArgumentException(sprintf('A "resource" attribute must be of type string for service "%s" in %s. Check your YAML syntax.', $id, $file)); 580 throw new InvalidArgumentException(sprintf('A "resource" attribute must be of type string for service "%s" in %s. Check your YAML syntax.', $id, $file));
581 } 581 }
582 $exclude = isset($service['exclude']) ? $service['exclude'] : null; 582 $exclude = isset($service['exclude']) ? $service['exclude'] : null;
583 $namespace = isset($service['namespace']) ? $service['namespace'] : $id; 583 $namespace = isset($service['namespace']) ? $service['namespace'] : $id;