|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
-
- namespace Lc\CaracoleBundle\Controller\User;
-
- use App\Entity\Address;
- use App\Form\Backend\Common\AddressType;
- use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
- use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
- use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
- use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter;
- use Lc\CaracoleBundle\Container\Address\AddressContainer;
- use Lc\CaracoleBundle\Controller\ControllerTrait;
- use Lc\SovBundle\Container\User\UserContainer;
- use Lc\CaracoleBundle\Controller\AbstractAdminController;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
- use Symfony\Component\HttpFoundation\Response;
-
- 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;
- }
- }
-
-
-
- }
|