Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

UserAdminController.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Lc\SovBundle\Controller\User;
  3. use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  6. use Lc\SovBundle\Controller\AbstractAdminController;
  7. use Lc\SovBundle\Definition\RolesDefinition;
  8. use Lc\SovBundle\Definition\RolesDefinitionInterface;
  9. use Lc\SovBundle\Doctrine\EntityManager;
  10. use Lc\SovBundle\Translation\TranslatorAdmin;
  11. use Symfony\Component\HttpFoundation\RequestStack;
  12. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  13. use function Symfony\Component\Translation\t;
  14. abstract class UserAdminController extends AbstractAdminController
  15. {
  16. protected $rolesDefinition;
  17. public function __construct(
  18. SessionInterface $session,
  19. RequestStack $request,
  20. EntityManager $em,
  21. TranslatorAdmin $translatorAdmin,
  22. RolesDefinitionInterface $rolesDefinition
  23. ) {
  24. parent::__construct($session, $request, $em, $translatorAdmin);
  25. $this->rolesDefinition = $rolesDefinition;
  26. }
  27. public function configureFields(string $pageName): iterable
  28. {
  29. return [
  30. EmailField::new('email'),
  31. TextField::new('lastname'),
  32. TextField::new('firstname'),
  33. ChoiceField::new('roles')
  34. ->allowMultipleChoices()
  35. ->autocomplete()
  36. ->setChoices($this->rolesDefinition->getRolesList())
  37. ];
  38. }
  39. }