← Back
Editing: UserCrudController.php
<?php namespace App\Controller\Admin; use App\Entity\User; use App\Enum\UserRole; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter; use Symfony\Component\Form\Extension\Core\Type\PasswordType; class UserCrudController extends AbstractCrudController { public static function getEntityFqcn(): string { return User::class; } public function configureFilters(Filters $filters): Filters { return $filters ->add('email') ->add('agency') ->add(TextFilter::new('manager')) ->add('roles'); } public function configureCrud(Crud $crud): Crud { return $crud // the visible title at the top of the page and the content of the <title> element // it can include these placeholders: %entity_id%, %entity_label_singular%, %entity_label_plural% ->setPageTitle('index', 'Utilisateurs'); } public function configureFields(string $pageName): iterable { return [ IdField::new('id')->hideOnForm(), AssociationField::new('agency'), AssociationField::new('organization')->setLabel('Organisme'), AssociationField::new('manager')->hideOnIndex(), TextField::new('username')->hideOnIndex(), TextField::new('email'), TextField::new('plainPassword')->setFormType(PasswordType::class)->onlyOnForms(), TextField::new('nom'), TextField::new('prenom'), ChoiceField::new('roles')->setChoices(UserRole::choices())->allowMultipleChoices(), AssociationField::new('managerAddresses') ->autocomplete() ->setFormTypeOptionIfNotSet('by_reference', false) ->setLabel('Peut gérer les adresses') ->hideOnIndex(), AssociationField::new('addressesAccess')->autocomplete()->setLabel( 'Peut faire des contrôles aux adresses' )->hideOnIndex(), BooleanField::new('superAdmin')->hideOnIndex(), NumberField::new('objectifControle')->hideOnIndex(), NumberField::new('rappel')->hideOnIndex(), AssociationField::new('solutions')->hideOnIndex(), BooleanField::new('isActive'), DateTimeField::new('updatedAt'), ]; } }
Save File
Cancel