1 | <?php |
||
12 | class JoinMapper extends AbstractMapper |
||
13 | { |
||
14 | /** |
||
15 | * @var ListMapper |
||
16 | */ |
||
17 | private $listMapper; |
||
18 | |||
19 | /** |
||
20 | * @var FilterMapper |
||
21 | */ |
||
22 | private $filterMapper; |
||
23 | |||
24 | /** |
||
25 | * JoinMapper constructor. |
||
26 | * |
||
27 | * @param ListMapper $listMapper fully built list mapper |
||
28 | * @param FilterMapper $filterMapper fully build filter mapper |
||
29 | */ |
||
30 | 9 | public function __construct( |
|
38 | |||
39 | /** |
||
40 | * @param string $path ORM path to join |
||
41 | * @param string $alias join as alias |
||
42 | * @param array $options |
||
43 | * |
||
44 | * @return JoinMapper |
||
45 | */ |
||
46 | 8 | public function add(string $path, string $alias, array $options = []): JoinMapper |
|
52 | |||
53 | /** |
||
54 | * @param string $path |
||
55 | * @param bool $lazy |
||
56 | * |
||
57 | * @return JoinField|null |
||
58 | */ |
||
59 | 11 | public function getByPath(string $path, bool $lazy = false): ?JoinField |
|
68 | |||
69 | /** |
||
70 | * @param bool|null $lazy |
||
71 | * |
||
72 | * @return ArrayCollection |
||
73 | */ |
||
74 | 6 | public function getFields(?bool $lazy = null): ArrayCollection |
|
84 | |||
85 | /** |
||
86 | * @return JoinMapper |
||
87 | */ |
||
88 | 2 | public function build(): self |
|
95 | |||
96 | 2 | private function buildListJoins(): void |
|
116 | |||
117 | 2 | private function buildFilterJoins(): void |
|
131 | |||
132 | /** |
||
133 | * @param array $paths |
||
134 | * @param string $joinType |
||
135 | * @param bool $lazy |
||
136 | */ |
||
137 | 2 | private function buildJoins(array $paths, string $joinType, bool $lazy): void |
|
152 | |||
153 | /** |
||
154 | * @param string $path join path |
||
155 | * @param array $options JoinField options |
||
156 | * @param string|null $alias join alias. If null - alias will be auto generated by replacing "." with "_" |
||
157 | * For example path = entity.parentEntity => alias = entity_parentEntity |
||
158 | * |
||
159 | * @return JoinField|null if nothing was joined |
||
160 | */ |
||
161 | 10 | private function addJoin(string $path, array $options, ?string $alias = null): ?JoinField |
|
192 | |||
193 | /** |
||
194 | * Removes last element (attribute) from path string |
||
195 | * For example order.user.name => order.user |
||
196 | * |
||
197 | * @param string $fullPath |
||
198 | * |
||
199 | * @return string|null |
||
200 | */ |
||
201 | 2 | private function getPath(string $fullPath): ?string |
|
213 | } |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: