-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIdentityGridTrait.php
More file actions
60 lines (52 loc) · 1.9 KB
/
Copy pathIdentityGridTrait.php
File metadata and controls
60 lines (52 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace ADT\FancyAdmin\UI\Components\Grids\Identity;
use ADT\Datagrid\Component\DataGrid;
use ADT\FancyAdmin\DI\Injects\EntityManagerInject;
use ADT\FancyAdmin\DI\Injects\IdentityQueryFactoryInject;
use ADT\FancyAdmin\DI\Injects\MailerInject;
use ADT\FancyAdmin\DI\Injects\SecurityUserInject;
use ADT\FancyAdmin\Model\Entities\Enums\AclResourceNameEnum;
use ADT\FancyAdmin\Model\Entities\Identity;
use ADT\FancyAdmin\Model\Queries\Factories\IdentityQueryFactory;
use ADT\FancyAdmin\UI\Components\Grids\Traits\AnonymizeIdentity\AnonymizeIdentity;
use ADT\FancyAdmin\UI\Components\Grids\Traits\Editable\Editable;
use ADT\FancyAdmin\UI\Components\Grids\Traits\IdentityData;
use ADT\FancyAdmin\UI\Components\Grids\Traits\ResetPassword\ResetPassword;
use ADT\FancyAdmin\UI\Components\Grids\Traits\SignInAsIdentity\SignInAsIdentity;
use ADT\FancyAdmin\UI\Presenters\SecurityCheckAttribute;
use Exception;
use ReflectionException;
trait IdentityGridTrait
{
use ResetPassword;
use Editable;
use SignInAsIdentity;
use IdentityData;
use AnonymizeIdentity;
public function initGrid(DataGrid $grid): void
{
$this->addIdentityData($grid);
$grid->addColumnText('roles', 'fcadmin.grids.user.labels.roles')
->setRenderer(function (Identity $identity) {
$roles = [];
foreach ($identity->getProfiles() as $profile) {
foreach ($profile->getRoles() as $role) {
$roles[$role->getId()] = $role->getName();
}
}
foreach ($identity->getRoles() as $role) {
$roles[$role->getId()] = $role->getName();
}
return implode(', ', $roles);
});
$grid->addColumnText('accounts', 'fcadmin.grids.user.labels.accounts')
->setRenderer(function (Identity $identity) {
return implode(', ', array_map(fn($account) => $account->getName(), $identity->getAccounts()));
});
}
protected function getQueryObjectFactoryClass(): string
{
return IdentityQueryFactory::class;
}
}