1 | <?php |
||
35 | class Factory extends ObjectAbstract implements FactoryInterface |
||
36 | { |
||
37 | use FactoryTrait; |
||
38 | |||
39 | /** |
||
40 | * @param Container $container |
||
41 | * @access public |
||
42 | */ |
||
43 | public function __construct(Container $container) |
||
47 | |||
48 | /** |
||
49 | * {@inheritDoc} |
||
50 | */ |
||
51 | public function createInstance(/*# string */ $rawId, array $arguments) |
||
71 | |||
72 | /** |
||
73 | * {@inheritDoc} |
||
74 | */ |
||
75 | public function executeCallable($callable, array $arguments = []) |
||
90 | |||
91 | /** |
||
92 | * {@inheritDoc} |
||
93 | */ |
||
94 | public function executeMethodBatch(array $methods, $object = null) |
||
100 | |||
101 | /** |
||
102 | * if $object provided, build callable like [$object, $method] and execute it. |
||
103 | * |
||
104 | * method: |
||
105 | * |
||
106 | * - callable |
||
107 | * |
||
108 | * - array ['function', [ arguments...]] |
||
109 | * |
||
110 | * - array [callable, [ arguments ...]] |
||
111 | * |
||
112 | * - array ['method', [ arguments ...]] |
||
113 | * will be converted to [[$object, 'method'], [ ... ]] |
||
114 | * |
||
115 | * @param array|callable method |
||
116 | * @param object|null $object to construct callable |
||
117 | * @throws LogicException if something goes wrong |
||
118 | * @access protected |
||
119 | */ |
||
120 | protected function executeMethod($method, $object = null) |
||
134 | |||
135 | /** |
||
136 | * Things to do after an object created. |
||
137 | * |
||
138 | * @param object $object |
||
139 | * @param array $definition service definition for $object |
||
140 | * @access protected |
||
141 | */ |
||
142 | protected function afterCreation($object, array $definition) |
||
154 | |||
155 | /** |
||
156 | * Execute common methods defined in 'di.common' for all objects |
||
157 | * |
||
158 | * Methods are in the form of |
||
159 | * |
||
160 | * [ interfaceOrClassname, [methodOrCallable, ArgumentsArray]], |
||
161 | * [ testCallable($obj, $container), [methodOrCallable, ArgumentsArray], |
||
162 | * ... |
||
163 | * |
||
164 | * @param object $object |
||
165 | * @return $this |
||
166 | * @access protected |
||
167 | */ |
||
168 | protected function executeCommonBatch($object) |
||
179 | |||
180 | /** |
||
181 | * Get common methods |
||
182 | * |
||
183 | * @return array |
||
184 | * @access protected |
||
185 | */ |
||
186 | protected function getCommonMethods()/*# : array */ |
||
205 | |||
206 | /** |
||
207 | * Merge different sections of a node |
||
208 | * |
||
209 | * convert |
||
210 | * `['section1' => [[1], [2]], 'section2' => [[3], [4]]]` |
||
211 | * |
||
212 | * to |
||
213 | * `[[1], [2], [3], [4]]` |
||
214 | * |
||
215 | * @param array|null $nodeData |
||
216 | * @return array |
||
217 | * @access protected |
||
218 | */ |
||
219 | protected function mergeMethods($nodeData)/*# : array */ |
||
233 | |||
234 | /** |
||
235 | * Returns [$object, $method] if it is a callable, otherwise returns $method |
||
236 | * |
||
237 | * @param mixed $object |
||
238 | * @param mixed $method |
||
239 | * @return bool |
||
240 | * @access protected |
||
241 | */ |
||
242 | protected function getObjectMethod($object, $method)/*# : bool */ |
||
255 | } |
||
256 |