1 | <?php |
||
24 | trait FactoryTrait |
||
25 | { |
||
26 | use AutowiringTrait; |
||
27 | |||
28 | /** |
||
29 | * fabricate the object using the definition |
||
30 | * |
||
31 | * @param array $definition |
||
32 | * @return object |
||
33 | * @throws LogicException if something goes wrong |
||
34 | * @throws UnresolvedClassException if parameter unresolved |
||
35 | */ |
||
36 | protected function fabricate(array $definition): object |
||
51 | |||
52 | /** |
||
53 | * fix object definition |
||
54 | * |
||
55 | * @param string|object|callable $definition |
||
56 | * @return array |
||
57 | */ |
||
58 | protected function fixDefinition($definition): array |
||
70 | |||
71 | /** |
||
72 | * Instantiate service object |
||
73 | * |
||
74 | * @param string $class class name |
||
75 | * @param array $arguments constructor arguments |
||
76 | * @return object |
||
77 | * @throws UnresolvedClassException |
||
78 | * @throws LogicException |
||
79 | */ |
||
80 | protected function constructObject(string $class, array $arguments): object |
||
99 | |||
100 | /** |
||
101 | * execute callable |
||
102 | * |
||
103 | * @param callable|object $callable callable |
||
104 | * @param array $arguments constructor arguments |
||
105 | * @return mixed |
||
106 | * @throws LogicException if something goes wrong |
||
107 | * @throws UnresolvedClassException if parameter unresolved |
||
108 | */ |
||
109 | protected function executeCallable($callable, array $arguments) |
||
130 | |||
131 | /** |
||
132 | * Processing service beforehand / aftermath |
||
133 | * |
||
134 | * @param array $definition service definition |
||
135 | * @param string $stage 'before' or 'after' |
||
136 | * @param object $object the created object |
||
137 | * @return object|null |
||
138 | * @throws UnresolvedClassException |
||
139 | * @throws LogicException |
||
140 | */ |
||
141 | protected function aroundConstruct( |
||
152 | |||
153 | /** |
||
154 | * fix methods in the 'after'|'before' part of definition |
||
155 | * |
||
156 | * @param array $line |
||
157 | * @param object|null $object |
||
158 | * @return array [Callable, arguments] |
||
159 | * @throws LogicException if goes wrong |
||
160 | */ |
||
161 | protected function fixMethod(array $line, ?object $object = NULL): array |
||
172 | } |