1 | <?php |
||
25 | class ManyToManyLoader extends RelationLoader |
||
26 | { |
||
27 | use WhereTrait; |
||
28 | |||
29 | /** |
||
30 | * When target role is null parent role to be used. Redefine this variable to revert behaviour |
||
31 | * of ManyToMany relation. |
||
32 | * |
||
33 | * @see ManyToMorphedRelation |
||
34 | * @var string|null |
||
35 | */ |
||
36 | private $targetRole = null; |
||
37 | |||
38 | /** |
||
39 | * Default set of relation options. Child implementation might defined their of default options. |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $options = [ |
||
44 | 'method' => self::POSTLOAD, |
||
45 | 'minify' => true, |
||
46 | 'alias' => null, |
||
47 | 'pivotAlias' => null, |
||
48 | 'using' => null, |
||
49 | 'where' => null, |
||
50 | 'wherePivot' => null |
||
51 | ]; |
||
52 | |||
53 | /** |
||
54 | * @param string $class |
||
55 | * @param string $relation |
||
56 | * @param array $schema |
||
57 | * @param \Spiral\ORM\ORMInterface $orm |
||
58 | * @param string|null $targetRole |
||
59 | */ |
||
60 | public function __construct( |
||
70 | |||
71 | /** |
||
72 | * {@inheritdoc} |
||
73 | * |
||
74 | * Visibility up. |
||
75 | */ |
||
76 | public function configureQuery(SelectQuery $query, array $outerKeys = []): SelectQuery |
||
146 | |||
147 | /** |
||
148 | * Set columns into SelectQuery. |
||
149 | * |
||
150 | * @param SelectQuery $query |
||
151 | * @param bool $minify Minify column names (will work in case when query parsed in |
||
152 | * FETCH_NUM mode). |
||
153 | * @param string $prefix Prefix to be added for each column name. |
||
154 | * @param bool $overwrite When set to true existed columns will be removed. |
||
155 | */ |
||
156 | protected function mountColumns( |
||
182 | |||
183 | /** |
||
184 | * {@inheritdoc} |
||
185 | */ |
||
186 | protected function initNode(): AbstractNode |
||
198 | |||
199 | /** |
||
200 | * Pivot table name. |
||
201 | * |
||
202 | * @return string |
||
203 | */ |
||
204 | protected function pivotTable(): string |
||
208 | |||
209 | /** |
||
210 | * Pivot table alias, depends on relation table alias. |
||
211 | * |
||
212 | * @return string |
||
213 | */ |
||
214 | protected function pivotAlias(): string |
||
222 | |||
223 | /** |
||
224 | * @return array |
||
225 | */ |
||
226 | protected function pivotColumns(): array |
||
230 | |||
231 | /** |
||
232 | * Key related to pivot table. Must include pivot table alias. |
||
233 | * |
||
234 | * @see pivotKey() |
||
235 | * |
||
236 | * @param string $key |
||
237 | * |
||
238 | * @return null|string |
||
239 | */ |
||
240 | protected function pivotKey(string $key) |
||
248 | |||
249 | /** |
||
250 | * Defined role to be used in morphed relations. |
||
251 | * |
||
252 | * @return string |
||
253 | */ |
||
254 | private function targetRole(): string |
||
261 | } |