Completed
Push — master ( d81c19...f57266 )
by Kamil
20s
created

AddressingBundle/Form/Type/ZoneChoiceType.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
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Sylius\Bundle\AddressingBundle\Form\Type;
15
16
use Sylius\Component\Resource\Repository\RepositoryInterface;
17
use Symfony\Component\Form\AbstractType;
18
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
19
use Symfony\Component\OptionsResolver\Options;
20
use Symfony\Component\OptionsResolver\OptionsResolver;
21
22
final class ZoneChoiceType extends AbstractType
23
{
24
    /**
25
     * @var RepositoryInterface
26
     */
27
    private $zoneRepository;
28
29
    /**
30
     * @param RepositoryInterface $zoneRepository
31
     */
32
    public function __construct(RepositoryInterface $zoneRepository)
33
    {
34
        $this->zoneRepository = $zoneRepository;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function configureOptions(OptionsResolver $resolver): void
41
    {
42
        $resolver->setDefaults([
43
            'choices' => function (Options $options): iterable {
0 ignored issues
show
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
                return $this->zoneRepository->findAll();
45
            },
46
            'choice_value' => 'code',
47
            'choice_label' => 'name',
48
            'choice_translation_domain' => false,
49
            'label' => 'sylius.form.address.zone',
50
            'placeholder' => 'sylius.form.zone.select',
51
        ]);
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getParent(): string
58
    {
59
        return ChoiceType::class;
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function getBlockPrefix(): string
66
    {
67
        return 'sylius_zone_choice';
68
    }
69
}
70