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.

77 lines
2.4KB

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