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\DoctrinePHPCRAdminBundle\Form\Type\Filter; |
15
|
|
|
|
16
|
|
|
use Sonata\AdminBundle\Form\Type\Filter\ChoiceType as BaseChoiceType; |
17
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType as SymfonyChoiceType; |
18
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
19
|
|
|
|
20
|
|
|
class ChoiceType extends BaseChoiceType |
21
|
|
|
{ |
22
|
|
|
public const TYPE_CONTAINS_WORDS = 4; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* NEXT_MAJOR: remove this method. |
26
|
|
|
*/ |
27
|
|
|
public function getName() |
28
|
|
|
{ |
29
|
|
|
return $this->getBlockPrefix(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* {@inheritdoc} |
34
|
|
|
*/ |
35
|
|
|
public function getBlockPrefix() |
36
|
|
|
{ |
37
|
|
|
return 'doctrine_phpcr_type_filter_choice'; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritdoc} |
42
|
|
|
*/ |
43
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void |
44
|
|
|
{ |
45
|
|
|
$choices = [ |
46
|
|
|
$this->translator->trans('label_type_contains', [], 'SonataAdminBundle') => self::TYPE_CONTAINS, |
|
|
|
|
47
|
|
|
$this->translator->trans('label_type_not_contains', [], 'SonataAdminBundle') => self::TYPE_NOT_CONTAINS, |
|
|
|
|
48
|
|
|
$this->translator->trans('label_type_equals', [], 'SonataAdminBundle') => self::TYPE_EQUAL, |
|
|
|
|
49
|
|
|
$this->translator->trans('label_type_contains_words', [], 'SonataDoctrinePHPCRAdmin') => self::TYPE_CONTAINS_WORDS, |
|
|
|
|
50
|
|
|
]; |
51
|
|
|
|
52
|
|
|
$builder |
53
|
|
|
->add('type', SymfonyChoiceType::class, [ |
54
|
|
|
'choices' => $choices, |
55
|
|
|
'required' => false, |
56
|
|
|
]) |
57
|
|
|
->add('value', $options['field_type'], array_merge(['required' => false], $options['field_options'])) |
58
|
|
|
; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
This property 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 property will be removed from the class and what other property to use instead.