You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.7KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Field\Configurator;
  3. use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField as EaAssociationField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface;
  6. use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
  7. use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
  8. use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory;
  9. use EasyCorp\Bundle\EasyAdminBundle\Field\Configurator\AssociationConfigurator as EaAssociationConfigurator;
  10. use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
  11. use Lc\CaracoleBundle\Field\AssociationField;
  12. use Symfony\Contracts\Translation\TranslatorInterface;
  13. /**
  14. * @author Javier Eguiluz <javier.eguiluz@gmail.com>
  15. */
  16. final class AssociationConfigurator implements FieldConfiguratorInterface
  17. {
  18. private $parent;
  19. private $entityFactory;
  20. private $adminUrlGenerator;
  21. private $translator;
  22. public function __construct(EaAssociationConfigurator $associationConfigurator, EntityFactory $entityFactory, AdminUrlGenerator $adminUrlGenerator, TranslatorInterface $translator)
  23. {
  24. $this->parent = $associationConfigurator;
  25. $this->entityFactory = $entityFactory;
  26. $this->adminUrlGenerator = $adminUrlGenerator;
  27. $this->translator = $translator;
  28. }
  29. public function supports(FieldDto $field, EntityDto $entityDto): bool
  30. {
  31. return AssociationField::class === $field->getFieldFqcn() || EaAssociationField::class === $field->getFieldFqcn();
  32. }
  33. public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $context): void
  34. {
  35. $this->parent->configure($field, $entityDto, $context);
  36. }
  37. }