Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

71 lines
2.2KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Controller\User;
  3. use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
  4. use Lc\CaracoleBundle\Controller\ControllerTrait;
  5. use Lc\SovBundle\Container\User\UserContainer;
  6. use Lc\CaracoleBundle\Controller\AbstractAdminController;
  7. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  8. abstract class UserAdminController extends AbstractAdminController
  9. {
  10. use ControllerTrait;
  11. public function getRepositoryQuery(): RepositoryQueryInterface
  12. {
  13. return $this->getUserContainer()->getRepositoryQuery();
  14. }
  15. public function createEntity(string $entityFqcn)
  16. {
  17. return $this->getUserContainer()->getFactory()->create();
  18. }
  19. public function configureFields(string $pageName): iterable
  20. {
  21. $fields = $this->get(UserContainer::class)
  22. ->getFieldDefinition()
  23. ->setMerchant($this->getMerchantCurrent())
  24. ->getAllFields();
  25. if ($pageName == Crud::PAGE_INDEX) {
  26. return [
  27. $fields['id'],
  28. $fields['gender'],
  29. $fields['lastname'],
  30. $fields['firstname'],
  31. $fields['email'],
  32. $fields['phone'],
  33. $fields['birthdate'],
  34. $fields['groupUsers'],
  35. $fields['isSaleAlwaysOpen'],
  36. $fields['newsletters']
  37. ];
  38. } elseif ($pageName == Crud::PAGE_EDIT || $pageName == Crud::PAGE_NEW) {
  39. $fieldToReturn = [
  40. $fields['id'],
  41. $fields['gender'],
  42. $fields['lastname'],
  43. $fields['firstname'],
  44. $fields['email'],
  45. $fields['phone'],
  46. $fields['birthdate'],
  47. $fields['groupUsers'],
  48. $fields['isSaleAlwaysOpen'],
  49. $fields['newsletters']
  50. ];
  51. if ($this->isGranted('ROLE_SUPER_ADMIN')) {
  52. $fieldToReturn[] = $fields['roles'];
  53. }
  54. return $fieldToReturn;
  55. } elseif ($pageName == Crud::PAGE_DETAIL) {
  56. return [$fields['id']];
  57. }
  58. }
  59. }