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.

44 lines
1.5KB

  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. abstract class UserAdminController extends AbstractAdminController
  14. {
  15. protected $rolesDefinition;
  16. public function __construct(
  17. SessionInterface $session,
  18. RequestStack $request,
  19. EntityManager $em,
  20. TranslatorAdmin $translatorAdmin,
  21. RolesDefinitionInterface $rolesDefinition
  22. ) {
  23. parent::__construct($session, $request, $em, $translatorAdmin);
  24. $this->rolesDefinition = $rolesDefinition;
  25. }
  26. public function configureFields(string $pageName): iterable
  27. {
  28. return [
  29. EmailField::new('email'),
  30. TextField::new('lastname'),
  31. TextField::new('firstname'),
  32. ChoiceField::new('roles')
  33. ->allowMultipleChoices()
  34. ->autocomplete()
  35. ->setChoices($this->rolesDefinition->getRolesList())
  36. ];
  37. }
  38. }