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\AdminBundle\Form\Type\Operator; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\Form\AbstractType; |
17
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType as FormChoiceType; |
18
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
19
|
|
|
|
20
|
|
|
final class StringOperatorType extends AbstractType |
21
|
|
|
{ |
22
|
|
|
public const TYPE_CONTAINS = 1; |
23
|
|
|
public const TYPE_NOT_CONTAINS = 2; |
24
|
|
|
public const TYPE_EQUAL = 3; |
25
|
|
|
public const TYPE_STARTS_WITH = 4; |
26
|
|
|
public const TYPE_ENDS_WITH = 5; |
27
|
|
|
|
28
|
|
|
public function configureOptions(OptionsResolver $resolver) |
29
|
|
|
{ |
30
|
|
|
$resolver->setDefaults([ |
31
|
|
|
'choice_translation_domain' => 'SonataAdminBundle', |
32
|
|
|
'choices' => [ |
33
|
|
|
'label_type_contains' => self::TYPE_CONTAINS, |
34
|
|
|
'label_type_not_contains' => self::TYPE_NOT_CONTAINS, |
35
|
|
|
'label_type_equals' => self::TYPE_EQUAL, |
36
|
|
|
'label_type_starts_with' => self::TYPE_STARTS_WITH, |
37
|
|
|
'label_type_ends_with' => self::TYPE_ENDS_WITH, |
38
|
|
|
], |
39
|
|
|
]); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function getParent() |
43
|
|
|
{ |
44
|
|
|
return FormChoiceType::class; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function getBlockPrefix() |
48
|
|
|
{ |
49
|
|
|
return 'sonata_type_operator_string'; |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|