Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Loader/Configurator/AbstractServiceConfigurator.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of the Symfony package. | |
5 * | |
6 * (c) Fabien Potencier <fabien@symfony.com> | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Symfony\Component\DependencyInjection\Loader\Configurator; | |
13 | |
14 use Symfony\Component\DependencyInjection\Definition; | |
15 use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; | |
16 | |
17 abstract class AbstractServiceConfigurator extends AbstractConfigurator | |
18 { | |
19 protected $parent; | |
20 protected $id; | |
21 private $defaultTags = array(); | |
22 | |
23 public function __construct(ServicesConfigurator $parent, Definition $definition, $id = null, array $defaultTags = array()) | |
24 { | |
25 $this->parent = $parent; | |
26 $this->definition = $definition; | |
27 $this->id = $id; | |
28 $this->defaultTags = $defaultTags; | |
29 } | |
30 | |
31 public function __destruct() | |
32 { | |
33 // default tags should be added last | |
34 foreach ($this->defaultTags as $name => $attributes) { | |
35 foreach ($attributes as $attributes) { | |
36 $this->definition->addTag($name, $attributes); | |
37 } | |
38 } | |
39 $this->defaultTags = array(); | |
40 } | |
41 | |
42 /** | |
43 * Registers a service. | |
44 * | |
45 * @param string $id | |
46 * @param string|null $class | |
47 * | |
48 * @return ServiceConfigurator | |
49 */ | |
50 final public function set($id, $class = null) | |
51 { | |
52 $this->__destruct(); | |
53 | |
54 return $this->parent->set($id, $class); | |
55 } | |
56 | |
57 /** | |
58 * Creates an alias. | |
59 * | |
60 * @param string $id | |
61 * @param string $referencedId | |
62 * | |
63 * @return AliasConfigurator | |
64 */ | |
65 final public function alias($id, $referencedId) | |
66 { | |
67 $this->__destruct(); | |
68 | |
69 return $this->parent->alias($id, $referencedId); | |
70 } | |
71 | |
72 /** | |
73 * Registers a PSR-4 namespace using a glob pattern. | |
74 * | |
75 * @param string $namespace | |
76 * @param string $resource | |
77 * | |
78 * @return PrototypeConfigurator | |
79 */ | |
80 final public function load($namespace, $resource) | |
81 { | |
82 $this->__destruct(); | |
83 | |
84 return $this->parent->load($namespace, $resource); | |
85 } | |
86 | |
87 /** | |
88 * Gets an already defined service definition. | |
89 * | |
90 * @param string $id | |
91 * | |
92 * @return ServiceConfigurator | |
93 * | |
94 * @throws ServiceNotFoundException if the service definition does not exist | |
95 */ | |
96 final public function get($id) | |
97 { | |
98 $this->__destruct(); | |
99 | |
100 return $this->parent->get($id); | |
101 } | |
102 | |
103 /** | |
104 * Registers a service. | |
105 * | |
106 * @param string $id | |
107 * @param string|null $class | |
108 * | |
109 * @return ServiceConfigurator | |
110 */ | |
111 final public function __invoke($id, $class = null) | |
112 { | |
113 $this->__destruct(); | |
114 | |
115 return $this->parent->set($id, $class); | |
116 } | |
117 } |