1 | <?php |
||
87 | class Container extends ObjectAbstract implements ContainerInterface, ScopeInterface, WritableInterface, \ArrayAccess, DelegatorAwareInterface, ExtendedContainerInterface |
||
88 | { |
||
89 | use ScopeTrait, |
||
90 | WritableTrait, |
||
91 | ArrayAccessTrait, |
||
92 | DelegatorAwareTrait, |
||
93 | ContainerHelperTrait, |
||
94 | InstanceFactoryTrait, |
||
95 | ExtendedContainerTrait; |
||
96 | |||
97 | /** |
||
98 | * Inject a Phossa2\Config\Config |
||
99 | * |
||
100 | * ```php |
||
101 | * $configData = [ |
||
102 | * // container class |
||
103 | * 'di.class' => 'Phossa2\\Di\\Container', |
||
104 | * |
||
105 | * // container service definitions |
||
106 | * 'di.service' => [ |
||
107 | * // ... |
||
108 | * ], |
||
109 | * |
||
110 | * // init methods to run after container created |
||
111 | * 'di.init' => [ |
||
112 | * 'default' => [], |
||
113 | * 'mystuff' => [ ... ], |
||
114 | * ], |
||
115 | * ]; |
||
116 | * |
||
117 | * // instantiate $config |
||
118 | * $config = new Config(null, null, $configData); |
||
119 | * |
||
120 | * // instantiate container |
||
121 | * $container = new $config['di.class']($config); |
||
122 | * ``` |
||
123 | * |
||
124 | * @param ConfigInterface $config inject the config instance |
||
125 | * @param string $baseNode container's starting node in $config |
||
126 | * @access public |
||
127 | */ |
||
128 | public function __construct( |
||
143 | |||
144 | // ContainerInterface related |
||
145 | |||
146 | /** |
||
147 | * Extensions to the Interop\Container\ContainerInterface |
||
148 | * |
||
149 | * - Accepting second param as object constructor arguments |
||
150 | * - Accpeting $id with scope appended, e.g. 'cache@myScope' |
||
151 | * |
||
152 | * {@inheritDoc} |
||
153 | */ |
||
154 | public function get($id) |
||
167 | |||
168 | /** |
||
169 | * Extensions to the Interop\Container\ContainerInterface |
||
170 | * |
||
171 | * - Accpeting $id with scope appended, e.g. 'cache@myScope' |
||
172 | * |
||
173 | * {@inheritDoc} |
||
174 | */ |
||
175 | public function has($id) |
||
184 | |||
185 | // WritableInterface related |
||
186 | |||
187 | /** |
||
188 | * {@inheritDoc} |
||
189 | */ |
||
190 | public function set(/*# string */ $id, $value) |
||
207 | |||
208 | /** |
||
209 | * Override 'isWritable()' in 'Phossa2\Config\Traits\WritableTrait' |
||
210 | * |
||
211 | * Container's writability is depend on its resolver |
||
212 | * |
||
213 | * {@inheritDoc} |
||
214 | */ |
||
215 | public function isWritable()/*# : bool */ |
||
219 | |||
220 | /** |
||
221 | * Override 'setWritable()' in 'Phossa2\Config\Traits\WritableTrait' |
||
222 | * |
||
223 | * Container's writability is depend on its resolver |
||
224 | * |
||
225 | * {@inheritDoc} |
||
226 | */ |
||
227 | public function setWritable($writable)/*# : bool */ |
||
231 | |||
232 | /** |
||
233 | * execute init methods defined in 'di.init' node |
||
234 | * |
||
235 | * @return $this |
||
236 | * @throws RuntimeException if anything goes wrong |
||
237 | * @access protected |
||
238 | */ |
||
239 | protected function initContainer() |
||
250 | } |
||
251 |