Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

#166 - Populate admin with users #181

Merged
merged 1 commit into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions config/packages/easy_admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }

18 changes: 18 additions & 0 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}