From 792e308cea1e65ff7c0bb242b69f9aca763d9ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomo=20=C5=A0ala?= Date: Wed, 10 Jan 2018 17:38:30 +0100 Subject: [PATCH] Handle Users in EasyAdmin backend EasyAdmin backend can now keep track of registered users, and can modify their roles. Closes #166 --- config/packages/easy_admin.yaml | 9 +++++++++ src/Entity/User.php | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/config/packages/easy_admin.yaml b/config/packages/easy_admin.yaml index 5ce85e0..90c17c4 100644 --- a/config/packages/easy_admin.yaml +++ b/config/packages/easy_admin.yaml @@ -18,4 +18,13 @@ easy_admin: - events - winners - noShows + Administrators: + class: App\Entity\User + list: + fields: + - username + - email + - enabled + - { property: 'roles', type: 'array'} + - { property: 'administrator', type: 'toggle' } diff --git a/src/Entity/User.php b/src/Entity/User.php index 9c3ec3f..efb412b 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -18,9 +18,27 @@ class User extends BaseUser */ protected $id; + /** + * @var bool + * + * Flags this user as admin (adds ROLE_SUPER_ADMIN) + */ + private $administrator; + public function __construct() { parent::__construct(); // your own logic } + + public function isAdministrator(): bool + { + return $this->isSuperAdmin(); + } + + public function setAdministrator($boolean) + { + $this->setSuperAdmin($boolean); + $this->administrator = $boolean; + } }