1 | <?php |
||
23 | class ContainerBuilder extends Container |
||
24 | { |
||
25 | /** |
||
26 | * @var Definition[] |
||
27 | */ |
||
28 | private $definitions = array(); |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | private $lockAlias = array(); |
||
34 | |||
35 | /** |
||
36 | * @var ArrayServiceLoader |
||
37 | */ |
||
38 | private $arrayLoader; |
||
39 | |||
40 | /** |
||
41 | * @var TagProcessor |
||
42 | */ |
||
43 | private $tagProcessor; |
||
44 | |||
45 | /** |
||
46 | * Constructor. |
||
47 | * |
||
48 | * @param ParameterBagInterface|null $parameterBag |
||
49 | * @param Di|null $di |
||
50 | */ |
||
51 | public function __construct(ParameterBagInterface $parameterBag = null, Di $di = null) |
||
57 | |||
58 | /** |
||
59 | * Clear and replace with sets of definitions. |
||
60 | * |
||
61 | * @param array $definitions |
||
62 | * |
||
63 | * @return static |
||
64 | */ |
||
65 | public function replaceDefinition(array $definitions) |
||
71 | |||
72 | /** |
||
73 | * Add sets of definition. |
||
74 | * |
||
75 | * @param array $definitions |
||
76 | * |
||
77 | * @return static |
||
78 | */ |
||
79 | public function addDefinition(array $definitions) |
||
87 | |||
88 | /** |
||
89 | * Set a service definition. |
||
90 | * |
||
91 | * @param string $id |
||
92 | * @param Definition $definition |
||
93 | * |
||
94 | * @return Definition |
||
95 | */ |
||
96 | public function setDefinition($id, Definition $definition) |
||
109 | |||
110 | /** |
||
111 | * Set service. |
||
112 | * |
||
113 | * @param string $id |
||
114 | * @param mixed $service |
||
115 | */ |
||
116 | public function set($id, $service) |
||
127 | |||
128 | /** |
||
129 | * {@inheritdoc} |
||
130 | */ |
||
131 | public function has($id) |
||
139 | |||
140 | /** |
||
141 | * Check if definition exists. |
||
142 | * |
||
143 | * @param string $id |
||
144 | * |
||
145 | * @return bool |
||
146 | */ |
||
147 | public function hasDefinition($id) |
||
151 | |||
152 | /** |
||
153 | * Get definition. |
||
154 | * |
||
155 | * @param string $id |
||
156 | * |
||
157 | * @return Definition |
||
158 | */ |
||
159 | public function getDefinition($id) |
||
169 | |||
170 | /** |
||
171 | * Get service. |
||
172 | * |
||
173 | * @param string $id |
||
174 | * @param array $args |
||
175 | * @param int $invalidBehavior |
||
176 | * |
||
177 | * @return mixed|object|null |
||
178 | */ |
||
179 | public function get($id, array $args = array(), $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) |
||
199 | |||
200 | /** |
||
201 | * Register service and map class alias if service is object. |
||
202 | * |
||
203 | * @param string $id |
||
204 | * @param mixed $service |
||
205 | * @param bool $shared |
||
206 | */ |
||
207 | public function register($id, $service, $shared = false) |
||
219 | |||
220 | /** |
||
221 | * Create service. |
||
222 | * |
||
223 | * @param Definition $definition |
||
224 | * @param array $args |
||
225 | * |
||
226 | * @return InstanceManager |
||
227 | */ |
||
228 | public function createService(Definition $definition, array $args = array()) |
||
240 | |||
241 | /** |
||
242 | * Load services from array. |
||
243 | * |
||
244 | * @param array $services |
||
245 | */ |
||
246 | public function load(array $services) |
||
250 | |||
251 | /** |
||
252 | * Add a tag. |
||
253 | * |
||
254 | * @param TagInterface $tag |
||
255 | */ |
||
256 | public function addTag(TagInterface $tag) |
||
260 | |||
261 | /** |
||
262 | * Register service definition. |
||
263 | * |
||
264 | * @param string $id |
||
265 | * @param Definition $definition |
||
266 | * @param array $args |
||
267 | * |
||
268 | * @return object |
||
269 | */ |
||
270 | private function registerDefinition($id, Definition $definition, array $args = array()) |
||
285 | |||
286 | /** |
||
287 | * Assert that service implement abstract. |
||
288 | * |
||
289 | * @param Definition $definition |
||
290 | * @param mixed $service |
||
291 | */ |
||
292 | private function assertImplementAbstract(Definition $definition, $service) |
||
304 | |||
305 | /** |
||
306 | * Fix alias. |
||
307 | * |
||
308 | * @param string $id |
||
309 | */ |
||
310 | private function removeAlias($id) |
||
321 | |||
322 | /** |
||
323 | * Register abstract definition if possible. |
||
324 | * |
||
325 | * @param string $id |
||
326 | * @param Definition $definition |
||
327 | */ |
||
328 | private function setAlias($id, Definition $definition) |
||
341 | } |
||
342 |