1 | <?php |
||
20 | class ModelFilter extends Filter |
||
21 | { |
||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data) |
||
26 | { |
||
27 | if (!$data || !is_array($data) || !array_key_exists('value', $data) || empty($data['value'])) { |
||
28 | return; |
||
29 | } |
||
30 | |||
31 | if ($data['value'] instanceof Collection) { |
||
32 | $data['value'] = $data['value']->toArray(); |
||
33 | } |
||
34 | |||
35 | if (!is_array($data['value'])) { |
||
36 | $data['value'] = array($data['value']); |
||
37 | } |
||
38 | |||
39 | $this->handleMultiple($queryBuilder, $alias, $data); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | public function getDefaultOptions() |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function getRenderSettings() |
||
70 | |||
71 | /** |
||
72 | * For the record, the $alias value is provided by the association method (and the entity join method) |
||
73 | * so the field value is not used here. |
||
74 | * |
||
75 | * @param ProxyQueryInterface|QueryBuilder $queryBuilder |
||
76 | * @param string $alias |
||
77 | * @param mixed $data |
||
78 | * |
||
79 | * @return mixed |
||
80 | */ |
||
81 | protected function handleMultiple(ProxyQueryInterface $queryBuilder, $alias, $data) |
||
111 | |||
112 | /** |
||
113 | * {@inheritdoc} |
||
114 | */ |
||
115 | protected function association(ProxyQueryInterface $queryBuilder, $data) |
||
134 | |||
135 | /** |
||
136 | * Retrieve the parent alias for given alias. |
||
137 | * Root alias for direct association or entity joined alias for association depth >= 2. |
||
138 | * |
||
139 | * @param ProxyQueryInterface $queryBuilder |
||
140 | * @param string $alias |
||
141 | * |
||
142 | * @return string |
||
143 | */ |
||
144 | private function getParentAlias(ProxyQueryInterface $queryBuilder, $alias) |
||
160 | } |
||
161 |