1 | <?php |
||
27 | class ManyToManyLoader extends RelationLoader |
||
28 | { |
||
29 | use WhereTrait, ConstrainTrait; |
||
30 | |||
31 | /** |
||
32 | * When target role is null parent role to be used. Redefine this variable to revert behaviour |
||
33 | * of ManyToMany relation. |
||
34 | * |
||
35 | * @see ManyToMorphedRelation |
||
36 | * @var string|null |
||
37 | */ |
||
38 | private $targetRole = null; |
||
39 | |||
40 | /** |
||
41 | * Default set of relation options. Child implementation might defined their of default options. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $options = [ |
||
46 | 'method' => self::POSTLOAD, |
||
47 | 'minify' => true, |
||
48 | 'alias' => null, |
||
49 | 'pivotAlias' => null, |
||
50 | 'using' => null, |
||
51 | 'where' => null, |
||
52 | 'wherePivot' => null, |
||
53 | 'orderBy' => [], |
||
54 | 'limit' => 0 |
||
55 | ]; |
||
56 | |||
57 | /** |
||
58 | * @param string $class |
||
59 | * @param string $relation |
||
60 | * @param array $schema |
||
61 | * @param \Spiral\ORM\ORMInterface $orm |
||
62 | * @param string|null $targetRole |
||
63 | */ |
||
64 | public function __construct( |
||
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | * |
||
83 | * Visibility up. |
||
84 | */ |
||
85 | public function configureQuery(SelectQuery $query, bool $loadColumns = true, array $outerKeys = []): SelectQuery |
||
157 | |||
158 | /** |
||
159 | * Set columns into SelectQuery. |
||
160 | * |
||
161 | * @param SelectQuery $query |
||
162 | * @param bool $minify Minify column names (will work in case when query parsed in |
||
163 | * FETCH_NUM mode). |
||
164 | * @param string $prefix Prefix to be added for each column name. |
||
165 | * @param bool $overwrite When set to true existed columns will be removed. |
||
166 | */ |
||
167 | protected function mountColumns( |
||
193 | |||
194 | /** |
||
195 | * {@inheritdoc} |
||
196 | */ |
||
197 | protected function initNode(): AbstractNode |
||
209 | |||
210 | /** |
||
211 | * Pivot table name. |
||
212 | * |
||
213 | * @return string |
||
214 | */ |
||
215 | protected function pivotTable(): string |
||
219 | |||
220 | /** |
||
221 | * Pivot table alias, depends on relation table alias. |
||
222 | * |
||
223 | * @return string |
||
224 | */ |
||
225 | protected function pivotAlias(): string |
||
233 | |||
234 | /** |
||
235 | * @return array |
||
236 | */ |
||
237 | protected function pivotColumns(): array |
||
241 | |||
242 | /** |
||
243 | * Key related to pivot table. Must include pivot table alias. |
||
244 | * |
||
245 | * @see pivotKey() |
||
246 | * |
||
247 | * @param string $key |
||
248 | * |
||
249 | * @return null|string |
||
250 | */ |
||
251 | protected function pivotKey(string $key) |
||
259 | |||
260 | /** |
||
261 | * Defined role to be used in morphed relations. |
||
262 | * |
||
263 | * @return string |
||
264 | */ |
||
265 | private function targetRole(): string |
||
272 | } |