1 | <?php |
||
36 | class Factory extends ObjectAbstract implements FactoryInterface |
||
37 | { |
||
38 | use ResolverAwareTrait, FactoryHelperTrait; |
||
39 | |||
40 | /** |
||
41 | * @param ResolverInterface |
||
42 | * @access public |
||
43 | */ |
||
44 | public function __construct(ResolverInterface $resolver) |
||
48 | |||
49 | /** |
||
50 | * {@inheritDoc} |
||
51 | */ |
||
52 | public function createInstance(/*# string */ $rawId, array $arguments) |
||
72 | |||
73 | /** |
||
74 | * {@inheritDoc} |
||
75 | */ |
||
76 | public function executeCallable($callable, array $arguments = []) |
||
91 | |||
92 | /** |
||
93 | * {@inheritDoc} |
||
94 | */ |
||
95 | public function executeMethodBatch(array $methods, $object = null) |
||
101 | |||
102 | /** |
||
103 | * if $object provided, build callable like [$object, $method] and execute it. |
||
104 | * |
||
105 | * method: |
||
106 | * |
||
107 | * - callable |
||
108 | * |
||
109 | * - array ['function', [ arguments...]] |
||
110 | * |
||
111 | * - array [callable, [ arguments ...]] |
||
112 | * |
||
113 | * - array ['method', [ arguments ...]] |
||
114 | * will be converted to [[$object, 'method'], [ ... ]] |
||
115 | * |
||
116 | * @param array|callable method |
||
117 | * @param object|null $object to construct callable |
||
118 | * @throws LogicException if something goes wrong |
||
119 | * @access protected |
||
120 | */ |
||
121 | protected function executeMethod($method, $object = null) |
||
135 | |||
136 | /** |
||
137 | * Things to do after an object created. |
||
138 | * |
||
139 | * @param object $object |
||
140 | * @param array $definition service definition for $object |
||
141 | * @access protected |
||
142 | */ |
||
143 | protected function afterCreation($object, array $definition) |
||
156 | |||
157 | /** |
||
158 | * Get common methods |
||
159 | * |
||
160 | * @return array |
||
161 | * @access protected |
||
162 | */ |
||
163 | protected function getCommonMethods()/*# : array */ |
||
172 | |||
173 | /** |
||
174 | * Merge different sections of a node |
||
175 | * |
||
176 | * convert |
||
177 | * `['section1' => [[1], [2]], 'section2' => [[3], [4]]]` |
||
178 | * |
||
179 | * to |
||
180 | * `[[1], [2], [3], [4]]` |
||
181 | * |
||
182 | * @param array|null $nodeData |
||
183 | * @return array |
||
184 | * @access protected |
||
185 | */ |
||
186 | protected function mergeMethods($nodeData)/*# : array */ |
||
200 | |||
201 | /** |
||
202 | * Returns [$object, $method] if it is a callable, otherwise returns $method |
||
203 | * |
||
204 | * @param mixed $object |
||
205 | * @param mixed $method |
||
206 | * @return bool |
||
207 | * @access protected |
||
208 | */ |
||
209 | protected function getObjectMethod($object, $method)/*# : bool */ |
||
222 | |||
223 | /** |
||
224 | * Get service definition |
||
225 | * |
||
226 | * @param string $rawId |
||
227 | * @param array $args |
||
228 | * @return array |
||
229 | * @access protected |
||
230 | */ |
||
231 | protected function getDefinition( |
||
250 | |||
251 | /** |
||
252 | * Get an object base on provided classname or interface name |
||
253 | * |
||
254 | * @param string $classname class or interface name |
||
255 | * @return object |
||
256 | * @throws \Exception if something goes wrong |
||
257 | * @access protected |
||
258 | */ |
||
259 | protected function getObjectByClass(/*# string */ $classname) |
||
270 | } |
||
271 |