1 | <?php |
||
19 | class RelationBucket |
||
20 | { |
||
21 | /** |
||
22 | * @var array|RelationInterface[] |
||
23 | */ |
||
24 | private $relations = []; |
||
25 | |||
26 | /** |
||
27 | * Parent class name. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | private $class; |
||
32 | |||
33 | /** |
||
34 | * Relations schema. |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | private $schema = []; |
||
39 | |||
40 | /** |
||
41 | * Associates ORM manager. |
||
42 | * |
||
43 | * @var ORMInterface |
||
44 | */ |
||
45 | protected $orm; |
||
46 | |||
47 | /** |
||
48 | * @param RecordInterface $record |
||
49 | * @param ORMInterface $orm |
||
50 | */ |
||
51 | public function __construct(RecordInterface $record, ORMInterface $orm) |
||
57 | |||
58 | /** |
||
59 | * Extract relations data from given entity fields. |
||
60 | * |
||
61 | * @param array $data |
||
62 | */ |
||
63 | public function extractRelations(array &$data) |
||
73 | |||
74 | /** |
||
75 | * Generate command tree with or without relation to parent command in order to specify update |
||
76 | * or insert sequence. Commands might define dependencies between each other in order to extend |
||
77 | * FK values. |
||
78 | * |
||
79 | * @param CommandInterface $parent |
||
80 | * |
||
81 | * @return CommandInterface |
||
82 | */ |
||
83 | public function queueRelations(CommandInterface $parent): CommandInterface |
||
109 | |||
110 | /** |
||
111 | * Check if parent entity has associated relation. |
||
112 | * |
||
113 | * @param string $relation |
||
114 | * |
||
115 | * @return bool |
||
116 | */ |
||
117 | public function has(string $relation): bool |
||
121 | |||
122 | /** |
||
123 | * Check if relation has any associated data with it (attention, non loaded relation will be |
||
124 | * automatically pre-loaded). |
||
125 | * |
||
126 | * @param string $relation |
||
127 | * |
||
128 | * @return bool |
||
129 | */ |
||
130 | public function hasRelated(string $relation): bool |
||
134 | |||
135 | /** |
||
136 | * Data data which is being associated with relation, relation is allowed to return itself if |
||
137 | * needed. |
||
138 | * |
||
139 | * @param string $relation |
||
140 | * |
||
141 | * @return RelationInterface|RecordInterface|mixed |
||
142 | * |
||
143 | * @throws RelationException |
||
144 | */ |
||
145 | public function getRelated(string $relation) |
||
149 | |||
150 | /** |
||
151 | * Associated relation with new value (must be compatible with relation format). |
||
152 | * |
||
153 | * @param string $relation |
||
154 | * @param mixed $value |
||
155 | * |
||
156 | * @throws RelationException |
||
157 | */ |
||
158 | public function setRelated(string $relation, $value) |
||
166 | |||
167 | /** |
||
168 | * De-associated relation data (idential to assign to null). |
||
169 | * |
||
170 | * @param string $relation |
||
171 | */ |
||
172 | public function flushRelated(string $relation) |
||
176 | |||
177 | /** |
||
178 | * Information about loaded relations. |
||
179 | * |
||
180 | * @return array |
||
181 | */ |
||
182 | public function __debugInfo() |
||
197 | |||
198 | /** |
||
199 | * Get associated relation instance. |
||
200 | * |
||
201 | * @param string $relation |
||
202 | * |
||
203 | * @return RelationInterface |
||
204 | */ |
||
205 | protected function get(string $relation): RelationInterface |
||
219 | |||
220 | /** |
||
221 | * list of relations which lead data of parent record (BELONGS_TO). |
||
222 | * |
||
223 | * Example: |
||
224 | * |
||
225 | * $post = new Post(); |
||
226 | * $post->user = new User(); |
||
227 | * |
||
228 | * @return RelationInterface[] |
||
229 | */ |
||
230 | protected function leadingRelations() |
||
234 | |||
235 | /** |
||
236 | * list of loaded relations which depend on parent record (HAS_MANY, MANY_TO_MANY and etc). |
||
237 | * |
||
238 | * Example: |
||
239 | * |
||
240 | * $post = new Post(); |
||
241 | * $post->comments->add(new Comment()); |
||
242 | * |
||
243 | * @return RelationInterface[] |
||
244 | */ |
||
245 | protected function dependedRelations() |
||
249 | } |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..