Completed
Push — master ( c4230c...3ebb49 )
by
unknown
08:37 queued 10s
created

src/Form/Type/Filter/ChoiceType.php (1 issue)

Upgrade to new PHP Analysis Engine

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\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
     * {@inheritdoc}
26
     *
27
     * @todo Remove when Symfony <2.8 is no longer supported
28
     */
29
    public function getName()
30
    {
31
        return $this->getBlockPrefix();
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function getBlockPrefix()
38
    {
39
        return 'doctrine_phpcr_type_filter_choice';
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function buildForm(FormBuilderInterface $builder, array $options): void
46
    {
47
        $choices = [
48
            $this->translator->trans('label_type_contains', [], 'SonataAdminBundle') => self::TYPE_CONTAINS,
49
            $this->translator->trans('label_type_not_contains', [], 'SonataAdminBundle') => self::TYPE_NOT_CONTAINS,
50
            $this->translator->trans('label_type_equals', [], 'SonataAdminBundle') => self::TYPE_EQUAL,
0 ignored issues
show
Deprecated Code introduced by
The property Sonata\AdminBundle\Form\...ChoiceType::$translator has been deprecated with message: since 3.5, to be removed with 4.0

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.

Loading history...
51
            $this->translator->trans('label_type_contains_words', [], 'SonataDoctrinePHPCRAdmin') => self::TYPE_CONTAINS_WORDS,
52
        ];
53
54
        $builder
55
            ->add('type', SymfonyChoiceType::class, [
56
                'choices' => $choices,
57
                'required' => false,
58
            ])
59
            ->add('value', $options['field_type'], array_merge(['required' => false], $options['field_options']))
60
        ;
61
    }
62
}
63