選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

46 行
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. 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. }