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.4KB

  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. $this->rolesDefinition = $rolesDefinition;
  24. }
  25. public function configureFields(string $pageName): iterable
  26. {
  27. return [
  28. EmailField::new('email'),
  29. TextField::new('lastname'),
  30. TextField::new('firstname'),
  31. ChoiceField::new('roles')
  32. ->allowMultipleChoices()
  33. ->autocomplete()
  34. ->setChoices($this->rolesDefinition->getRolesList())
  35. ];
  36. }
  37. }