vendor/sylius/sylius/src/Sylius/Bundle/AddressingBundle/Form/Type/CountryCodeChoiceType.php line 22

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sylius package.
  4.  *
  5.  * (c) Paweł Jędrzejewski
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace Sylius\Bundle\AddressingBundle\Form\Type;
  12. use Sylius\Bundle\ResourceBundle\Form\DataTransformer\ResourceToIdentifierTransformer;
  13. use Sylius\Component\Resource\Repository\RepositoryInterface;
  14. use Symfony\Component\Form\AbstractType;
  15. use Symfony\Component\Form\FormBuilderInterface;
  16. use Symfony\Component\Form\ReversedTransformer;
  17. final class CountryCodeChoiceType extends AbstractType
  18. {
  19.     /** @var RepositoryInterface */
  20.     private $countryRepository;
  21.     public function __construct(RepositoryInterface $countryRepository)
  22.     {
  23.         $this->countryRepository $countryRepository;
  24.     }
  25.     public function buildForm(FormBuilderInterface $builder, array $options): void
  26.     {
  27.         $builder->addModelTransformer(new ReversedTransformer(new ResourceToIdentifierTransformer($this->countryRepository'code')));
  28.     }
  29.     public function getParent(): string
  30.     {
  31.         return CountryChoiceType::class;
  32.     }
  33.     public function getBlockPrefix(): string
  34.     {
  35.         return 'sylius_country_code_choice';
  36.     }
  37. }