vendor/se7enxweb/admin-ui/src/lib/Form/Type/Content/LocationType.php line 19

Open in your IDE?
  1. <?php
  2. /**
  3. * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4. * @license For full copyright and license information view LICENSE file distributed with this source code.
  5. */
  6. declare(strict_types=1);
  7. namespace Ibexa\AdminUi\Form\Type\Content;
  8. use Ibexa\AdminUi\Form\DataTransformer\LocationsTransformer;
  9. use Ibexa\AdminUi\Form\DataTransformer\LocationTransformer;
  10. use Ibexa\Contracts\Core\Repository\LocationService;
  11. use Symfony\Component\Form\AbstractType;
  12. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  13. use Symfony\Component\Form\FormBuilderInterface;
  14. use Symfony\Component\OptionsResolver\OptionsResolver;
  15. class LocationType extends AbstractType
  16. {
  17. /** @var \Ibexa\Contracts\Core\Repository\LocationService */
  18. protected $locationService;
  19. /**
  20. * @param \Ibexa\Contracts\Core\Repository\LocationService $locationService
  21. */
  22. public function __construct(LocationService $locationService)
  23. {
  24. $this->locationService = $locationService;
  25. }
  26. public function buildForm(FormBuilderInterface $builder, array $options)
  27. {
  28. $builder->addViewTransformer(
  29. $options['multiple']
  30. ? new LocationsTransformer($this->locationService)
  31. : new LocationTransformer($this->locationService)
  32. );
  33. }
  34. public function configureOptions(OptionsResolver $resolver)
  35. {
  36. $resolver->setDefault('multiple', false);
  37. $resolver->setRequired(['multiple']);
  38. $resolver->setAllowedTypes('multiple', 'boolean');
  39. }
  40. public function getParent(): ?string
  41. {
  42. return HiddenType::class;
  43. }
  44. }
  45. class_alias(LocationType::class, 'EzSystems\EzPlatformAdminUi\Form\Type\Content\LocationType');