1 | <?php |
||
23 | class RootLoader extends AbstractLoader |
||
24 | { |
||
25 | use ColumnsTrait; |
||
26 | |||
27 | /** |
||
28 | * Root loader always define primary SelectQuery. |
||
29 | * |
||
30 | * @var SelectQuery |
||
31 | */ |
||
32 | private $query; |
||
33 | |||
34 | /** |
||
35 | * Only columns to be selected, by default all columns. |
||
36 | * |
||
37 | * @var null|array |
||
38 | */ |
||
39 | private $columns = null; |
||
40 | |||
41 | /** |
||
42 | * @param string $class |
||
43 | * @param array $schema Record schema for root loader. |
||
44 | * @param ORMInterface $orm |
||
45 | */ |
||
46 | public function __construct(string $class, array $schema, ORMInterface $orm) |
||
61 | |||
62 | /** |
||
63 | * Columns to be selected, please note, primary will always be included, DO not include |
||
64 | * column aliases in here, aliases will be added automatically. Creates new loader tree copy. |
||
65 | * |
||
66 | * @param array $columns |
||
67 | * |
||
68 | * @return RootLoader |
||
69 | */ |
||
70 | public function withColumns(array $columns): self |
||
80 | |||
81 | /** |
||
82 | * Return initial loader query (attention, mutable instance). |
||
83 | * |
||
84 | * @return SelectQuery |
||
85 | */ |
||
86 | public function initialQuery(): SelectQuery |
||
90 | |||
91 | /** |
||
92 | * Return build version of query. |
||
93 | * |
||
94 | * @return SelectQuery |
||
95 | */ |
||
96 | public function compiledQuery(): SelectQuery |
||
100 | |||
101 | /** |
||
102 | * Get primary key column if possible (aliased). Null when key is missing or non singular. |
||
103 | * |
||
104 | * @return string|null |
||
105 | */ |
||
106 | public function primaryKey(): string |
||
110 | |||
111 | /** |
||
112 | * We are using model role as alias. Visibility up. |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | public function getAlias(): string |
||
120 | |||
121 | /** |
||
122 | * @param SelectQuery $query |
||
123 | * |
||
124 | * @return SelectQuery |
||
125 | */ |
||
126 | protected function configureQuery(SelectQuery $query): SelectQuery |
||
136 | |||
137 | /** |
||
138 | * {@inheritdoc} |
||
139 | */ |
||
140 | public function loadData(AbstractNode $node) |
||
158 | |||
159 | /** |
||
160 | * {@inheritdoc} |
||
161 | */ |
||
162 | public function initNode(): AbstractNode |
||
169 | |||
170 | /** |
||
171 | * Clone with initial query. |
||
172 | */ |
||
173 | public function __clone() |
||
178 | |||
179 | /** |
||
180 | * Relation columns. |
||
181 | * |
||
182 | * @return array |
||
183 | */ |
||
184 | protected function getColumns(): array |
||
188 | } |