1 | <?php |
||
85 | class Container extends ObjectAbstract implements ContainerInterface, ScopeInterface, WritableInterface, \ArrayAccess, DelegatorAwareInterface, ExtendedContainerInterface |
||
86 | { |
||
87 | use WritableTrait, |
||
88 | ArrayAccessTrait, |
||
89 | DelegatorAwareTrait, |
||
90 | InstanceFactoryTrait; |
||
91 | |||
92 | /** |
||
93 | * Inject a Phossa2\Config\Config |
||
94 | * |
||
95 | * ```php |
||
96 | * $configData = [ |
||
97 | * // container class |
||
98 | * 'di.class' => 'Phossa2\\Di\\Container', |
||
99 | * |
||
100 | * // container service definitions |
||
101 | * 'di.service' => [ |
||
102 | * // ... |
||
103 | * ], |
||
104 | * |
||
105 | * // init methods to run after container created |
||
106 | * 'di.init' => [ |
||
107 | * 'default' => [], |
||
108 | * 'mystuff' => [ ... ], |
||
109 | * ], |
||
110 | * ]; |
||
111 | * |
||
112 | * // instantiate $config |
||
113 | * $config = new Config(null, null, $configData); |
||
114 | * |
||
115 | * // instantiate container |
||
116 | * $container = new $config['di.class']($config); |
||
117 | * ``` |
||
118 | * |
||
119 | * @param ConfigInterface $config inject the config instance |
||
120 | * @param string $baseNode container's starting node in $config |
||
121 | * @access public |
||
122 | */ |
||
123 | public function __construct( |
||
142 | |||
143 | // ContainerInterface related |
||
144 | |||
145 | /** |
||
146 | * Extensions to the Interop\Container\ContainerInterface |
||
147 | * |
||
148 | * - Accepting second param as object constructor arguments |
||
149 | * - Accpeting $id with scope appended, e.g. 'cache@myScope' |
||
150 | * |
||
151 | * {@inheritDoc} |
||
152 | */ |
||
153 | public function get($id) |
||
166 | |||
167 | /** |
||
168 | * Extensions to the Interop\Container\ContainerInterface |
||
169 | * |
||
170 | * - Accpeting $id with scope appended, e.g. 'cache@myScope' |
||
171 | * |
||
172 | * {@inheritDoc} |
||
173 | */ |
||
174 | public function has($id) |
||
183 | |||
184 | // ExtendedContainerInterface |
||
185 | |||
186 | /** |
||
187 | * {@inheritDoc} |
||
188 | */ |
||
189 | public function one(/*# string */ $id, array $arguments = []) |
||
196 | |||
197 | /** |
||
198 | * {@inheritDoc} |
||
199 | */ |
||
200 | public function run($callable, array $arguments = []) |
||
207 | |||
208 | /** |
||
209 | * {@inheritDoc} |
||
210 | */ |
||
211 | public function param(/*# string */ $name, $value)/*# : bool */ |
||
219 | |||
220 | /** |
||
221 | * {@inheritDoc} |
||
222 | */ |
||
223 | public function alias(/*# string */ $id, $object)/*# : bool */ |
||
230 | |||
231 | // AutoWiringInterface related |
||
232 | |||
233 | /** |
||
234 | * {@inheritDoc} |
||
235 | */ |
||
236 | public function auto(/*# bool */ $flag = true) |
||
241 | |||
242 | /** |
||
243 | * {@inheritDoc} |
||
244 | */ |
||
245 | public function isAuto()/*# : bool */ |
||
249 | |||
250 | // AutoTranslationInterface related |
||
251 | |||
252 | /** |
||
253 | * {@inheritDoc} |
||
254 | * |
||
255 | * @since 2.1.0 added |
||
256 | */ |
||
257 | public function translation(/*# bool */ $flag = true) |
||
262 | |||
263 | // ReferenceResolveInterface related |
||
264 | |||
265 | /** |
||
266 | * {@inheritDoc} |
||
267 | */ |
||
268 | public function resolve(&$toResolve) |
||
273 | |||
274 | // ScopeInterface related |
||
275 | |||
276 | /** |
||
277 | * @inheritDoc |
||
278 | */ |
||
279 | public function share(/*# bool */ $flag = true) |
||
285 | |||
286 | // WritableInterface related |
||
287 | |||
288 | /** |
||
289 | * {@inheritDoc} |
||
290 | */ |
||
291 | public function set(/*# string */ $id, $value)/*# : bool */ |
||
307 | |||
308 | /** |
||
309 | * Override 'isWritable()' in 'Phossa2\Config\Traits\WritableTrait' |
||
310 | * |
||
311 | * Container's writability is depend on its resolver |
||
312 | * |
||
313 | * {@inheritDoc} |
||
314 | */ |
||
315 | public function isWritable()/*# : bool */ |
||
319 | |||
320 | /** |
||
321 | * Override 'setWritable()' in 'Phossa2\Config\Traits\WritableTrait' |
||
322 | * |
||
323 | * Container's writability is depend on its resolver |
||
324 | * |
||
325 | * {@inheritDoc} |
||
326 | */ |
||
327 | public function setWritable($writable)/*# : bool */ |
||
331 | } |
||
332 |