These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * This file is part of the Sonata Project package. |
||
7 | * |
||
8 | * (c) Thomas Rabaix <[email protected]> |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | namespace Sonata\DoctrineMongoDBAdminBundle\Filter; |
||
15 | |||
16 | use Sonata\AdminBundle\Datagrid\ProxyQueryInterface; |
||
17 | use Sonata\AdminBundle\Form\Type\Filter\ChoiceType; |
||
18 | use Sonata\AdminBundle\Form\Type\Filter\DefaultType; |
||
19 | use Sonata\Form\Type\BooleanType; |
||
20 | |||
21 | class ChoiceFilter extends Filter |
||
22 | { |
||
23 | /** |
||
24 | * @param string $alias |
||
25 | * @param string $field |
||
26 | * @param mixed $data |
||
27 | */ |
||
28 | public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data): void |
||
29 | { |
||
30 | if (!$data || !\is_array($data) || !\array_key_exists('type', $data) || !\array_key_exists('value', $data)) { |
||
31 | return; |
||
32 | } |
||
33 | |||
34 | if (\is_array($data['value'])) { |
||
35 | if (0 === \count($data['value'])) { |
||
36 | return; |
||
37 | } |
||
38 | |||
39 | if (ChoiceType::TYPE_NOT_CONTAINS === $data['type']) { |
||
0 ignored issues
–
show
|
|||
40 | $queryBuilder->field($field)->notIn($data['value']); |
||
41 | } else { |
||
42 | $queryBuilder->field($field)->in($data['value']); |
||
43 | } |
||
44 | |||
45 | $this->active = true; |
||
46 | } else { |
||
47 | if ('' === $data['value'] || null === $data['value'] || false === $data['value']) { |
||
48 | return; |
||
49 | } |
||
50 | |||
51 | if (ChoiceType::TYPE_NOT_CONTAINS === $data['type']) { |
||
0 ignored issues
–
show
The constant
Sonata\AdminBundle\Form\...Type::TYPE_NOT_CONTAINS has been deprecated with message: since sonata-project/admin-bundle 3.57, to be removed with 4.0: Use ContainsOperatorType::TYPE_NOT_CONTAINS instead
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.
Loading history...
|
|||
52 | $queryBuilder->field($field)->notEqual($data['value']); |
||
53 | } else { |
||
54 | $queryBuilder->field($field)->equals($data['value']); |
||
55 | } |
||
56 | |||
57 | $this->active = true; |
||
58 | } |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return array |
||
63 | */ |
||
64 | public function getDefaultOptions() |
||
65 | { |
||
66 | return []; |
||
67 | } |
||
68 | |||
69 | public function getRenderSettings() |
||
70 | { |
||
71 | return [DefaultType::class, [ |
||
72 | 'operator_type' => BooleanType::class, |
||
73 | 'field_type' => $this->getFieldType(), |
||
74 | 'field_options' => $this->getFieldOptions(), |
||
75 | 'label' => $this->getLabel(), |
||
76 | ]]; |
||
77 | } |
||
78 | } |
||
79 |
This class constant has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.