1 | <?php |
||
16 | class InheritanceDefinition |
||
17 | { |
||
18 | /** |
||
19 | * @var DocumentSchema |
||
20 | */ |
||
21 | private $schema; |
||
22 | |||
23 | /** |
||
24 | * All other registered schemas. |
||
25 | * |
||
26 | * @var SchemaInterface[] |
||
27 | */ |
||
28 | private $schemas = []; |
||
29 | |||
30 | /** |
||
31 | * @param DocumentSchema $schema |
||
32 | * @param SchemaInterface[] $schemas |
||
33 | */ |
||
34 | public function __construct(DocumentSchema $schema, array $schemas) |
||
39 | |||
40 | /** |
||
41 | * Compile information required to resolve class instance using given set of fields. Fields |
||
42 | * based definition will analyze unique fields in every child model to create association |
||
43 | * between model class and required set of fields. Only document from same collection will be |
||
44 | * involved in definition creation. Definition built only for child of first order. |
||
45 | * |
||
46 | * @return array|string |
||
47 | * |
||
48 | * @throws DefinitionException |
||
49 | */ |
||
50 | public function makeDefinition() |
||
106 | |||
107 | /** |
||
108 | * Get Document child classes. |
||
109 | * |
||
110 | * Example: |
||
111 | * Class A |
||
112 | * Class B extends A |
||
113 | * Class D extends A |
||
114 | * Class E extends D |
||
115 | * |
||
116 | * Result: B, D, E |
||
117 | * |
||
118 | * @see getPrimary() |
||
119 | * |
||
120 | * @param bool $sameCollection Find only children related to same collection as parent. |
||
121 | * @param bool $directChildren Only child extended directly from current document. |
||
122 | * |
||
123 | * @return DocumentSchema[] |
||
124 | */ |
||
125 | public function findChildren(bool $sameCollection = false, bool $directChildren = false) |
||
158 | |||
159 | /** |
||
160 | * @return ReflectionEntity |
||
161 | */ |
||
162 | protected function getReflection(): ReflectionEntity |
||
166 | |||
167 | /** |
||
168 | * Check if both document schemas belongs to same collection. Documents without declared |
||
169 | * collection must be counted as documents from same collection. |
||
170 | * |
||
171 | * @param DocumentSchema $document |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | protected function compareCollection(DocumentSchema $document) |
||
183 | |||
184 | /** |
||
185 | * Sort child documents in order or declared fields. |
||
186 | * |
||
187 | * @param DocumentSchema $childA |
||
188 | * @param DocumentSchema $childB |
||
189 | * |
||
190 | * @return int |
||
191 | */ |
||
192 | private function sortChildren(DocumentSchema $childA, DocumentSchema $childB) |
||
196 | } |