1 | <?php |
||
15 | class Container implements ContainerInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var \League\Container\Definition\DefinitionFactoryInterface |
||
19 | */ |
||
20 | protected $definitionFactory; |
||
21 | |||
22 | /** |
||
23 | * @var \League\Container\Definition\DefinitionInterface[] |
||
24 | */ |
||
25 | protected $definitions = []; |
||
26 | |||
27 | /** |
||
28 | * @var \League\Container\Definition\DefinitionInterface[] |
||
29 | */ |
||
30 | protected $sharedDefinitions = []; |
||
31 | |||
32 | /** |
||
33 | * @var \League\Container\Inflector\InflectorAggregateInterface |
||
34 | */ |
||
35 | protected $inflectors; |
||
36 | |||
37 | /** |
||
38 | * @var \League\Container\ServiceProvider\ServiceProviderAggregateInterface |
||
39 | */ |
||
40 | protected $providers; |
||
41 | |||
42 | /** |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $shared = []; |
||
46 | |||
47 | /** |
||
48 | * @var \Interop\Container\ContainerInterface[] |
||
49 | */ |
||
50 | protected $delegates = []; |
||
51 | |||
52 | /** |
||
53 | * Constructor. |
||
54 | * |
||
55 | * @param \League\Container\ServiceProvider\ServiceProviderAggregateInterface|null $providers |
||
56 | * @param \League\Container\Inflector\InflectorAggregateInterface|null $inflectors |
||
57 | * @param \League\Container\Definition\DefinitionFactoryInterface|null $definitionFactory |
||
58 | */ |
||
59 | 54 | public function __construct( |
|
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | 42 | public function get($alias, array $args = []) |
|
97 | |||
98 | /** |
||
99 | * {@inheritdoc} |
||
100 | */ |
||
101 | 18 | public function has($alias) |
|
113 | |||
114 | /** |
||
115 | * Returns a boolean to determine if the container has a shared instance of an alias. |
||
116 | * |
||
117 | * @param string $alias |
||
118 | * @param boolean $resolved |
||
119 | * @return boolean |
||
120 | */ |
||
121 | 48 | public function hasShared($alias, $resolved = false) |
|
127 | |||
128 | /** |
||
129 | * {@inheritdoc} |
||
130 | */ |
||
131 | 42 | public function add($alias, $concrete = null, $share = false) |
|
156 | |||
157 | /** |
||
158 | * {@inheritdoc} |
||
159 | */ |
||
160 | 33 | public function share($alias, $concrete = null) |
|
164 | |||
165 | /** |
||
166 | * {@inheritdoc} |
||
167 | */ |
||
168 | 12 | public function addServiceProvider($provider) |
|
174 | |||
175 | /** |
||
176 | * {@inheritdoc} |
||
177 | */ |
||
178 | 6 | public function extend($alias) |
|
196 | |||
197 | /** |
||
198 | * {@inheritdoc} |
||
199 | */ |
||
200 | public function inflector($type, callable $callback = null) |
||
204 | |||
205 | /** |
||
206 | * {@inheritdoc} |
||
207 | */ |
||
208 | public function call(callable $callable, array $args = []) |
||
212 | |||
213 | /** |
||
214 | * Delegate a backup container to be checked for services if it |
||
215 | * cannot be resolved via this container. |
||
216 | * |
||
217 | * @param \Interop\Container\ContainerInterface $container |
||
218 | * @return $this |
||
219 | */ |
||
220 | 9 | public function delegate(InteropContainerInterface $container) |
|
230 | |||
231 | /** |
||
232 | * Returns true if service is registered in one of the delegated backup containers. |
||
233 | * |
||
234 | * @param string $alias |
||
235 | * @return boolean |
||
236 | */ |
||
237 | 9 | public function hasInDelegate($alias) |
|
247 | |||
248 | /** |
||
249 | * Attempt to get a service from the stack of delegated backup containers. |
||
250 | * |
||
251 | * @param string $alias |
||
252 | * @param array $args |
||
253 | * @return mixed |
||
254 | */ |
||
255 | 9 | protected function getFromDelegate($alias, array $args = []) |
|
270 | |||
271 | /** |
||
272 | * Get a service that has been registered in this container. |
||
273 | * |
||
274 | * @param string $alias |
||
275 | * @param array $args |
||
276 | * @return mixed |
||
277 | */ |
||
278 | 42 | protected function getFromThisContainer($alias, array $args = []) |
|
300 | } |
||
301 |