|
- <?php
-
- namespace Lc\CaracoleBundle\Controller\User;
-
-
- use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
- use Lc\CaracoleBundle\Controller\ControllerTrait;
- use Lc\SovBundle\Container\User\UserContainer;
- use Lc\CaracoleBundle\Controller\AbstractAdminController;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
-
- abstract class UserAdminController extends AbstractAdminController
- {
- use ControllerTrait;
-
- public function getRepositoryQuery(): RepositoryQueryInterface
- {
- return $this->getUserContainer()->getRepositoryQuery();
- }
-
- public function createEntity(string $entityFqcn)
- {
- return $this->getUserContainer()->getFactory()->create();
- }
-
- public function configureFields(string $pageName): iterable
- {
- $fields = $this->get(UserContainer::class)
- ->getFieldDefinition()
- ->setMerchant($this->getMerchantCurrent())
- ->getAllFields();
-
- if ($pageName == Crud::PAGE_INDEX) {
- return [
- $fields['id'],
- $fields['gender'],
- $fields['lastname'],
- $fields['firstname'],
- $fields['email'],
- $fields['phone'],
- $fields['birthdate'],
- $fields['groupUsers'],
- $fields['isSaleAlwaysOpen'],
- $fields['newsletters']
- ];
- } elseif ($pageName == Crud::PAGE_EDIT || $pageName == Crud::PAGE_NEW) {
- $fieldToReturn = [
- $fields['id'],
- $fields['gender'],
- $fields['lastname'],
- $fields['firstname'],
- $fields['email'],
- $fields['phone'],
- $fields['birthdate'],
- $fields['groupUsers'],
- $fields['isSaleAlwaysOpen'],
- $fields['newsletters']
- ];
-
- if ($this->isGranted('ROLE_SUPER_ADMIN')) {
- $fieldToReturn[] = $fields['roles'];
- }
- return $fieldToReturn;
- } elseif ($pageName == Crud::PAGE_DETAIL) {
- return [$fields['id']];
- }
- }
-
-
- }
|