From ba9ff09b54523c3291bcb102dce7a38040ec4736 Mon Sep 17 00:00:00 2001 From: tracer Date: Tue, 12 Apr 2022 19:01:14 +0200 Subject: [PATCH] reorganized menu --- src/Controller/Admin/UserCrudController.php | 27 +++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/Controller/Admin/UserCrudController.php b/src/Controller/Admin/UserCrudController.php index 866f6c2..142417e 100644 --- a/src/Controller/Admin/UserCrudController.php +++ b/src/Controller/Admin/UserCrudController.php @@ -4,6 +4,11 @@ namespace App\Controller\Admin; use App\Entity\User; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; +use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; +use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField; +use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; +use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField; +use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; /** * @@ -15,14 +20,22 @@ class UserCrudController extends AbstractCrudController return User::class; } - /* public function configureFields(string $pageName): iterable { - return [ - IdField::new('id'), - TextField::new('title'), - TextEditorField::new('description'), - ]; + yield IdField::new(propertyName: 'id') + ->onlyOnIndex(); + yield TextField::new(propertyName: 'firstName'); + yield TextField::new(propertyName: 'lastName'); + yield EmailField::new(propertyName: 'email'); + yield ImageField::new(propertyName: 'avatar') + ->setBasePath(path: 'uploads/avatars') + ->setUploadDir(uploadDirPath: 'public/uploads/avatars') + ->setUploadedFileNamePattern(patternOrCallable: '[timestamp]-[slug].[extension]'); + $roles = ['ROLE_FOUNDER', 'ROLE_ADMIN', 'ROLE_MODERATOR', 'ROLE_USER']; + yield ChoiceField::new(propertyName: 'roles') + ->setChoices(choiceGenerator: array_combine(keys: $roles, values: $roles)) + ->allowMultipleChoices() + ->renderExpanded() + ->renderAsBadges(); } - */ }