1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\UserManagementBundle\AdminList; |
4
|
|
|
|
5
|
|
|
use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM\BooleanFilterType; |
6
|
|
|
use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM\StringFilterType; |
7
|
|
|
use Kunstmaan\UserManagementBundle\AdminList\ItemAction\UserDeleteItemAction; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* User admin list configurator used to manage {@link User} in the admin |
11
|
|
|
*/ |
12
|
|
|
class UserAdminListConfigurator extends AbstractSettingsAdminListConfigurator |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Build filters for admin list |
16
|
|
|
*/ |
17
|
|
|
public function buildFilters() |
18
|
|
|
{ |
19
|
|
|
$this->addFilter('username', new StringFilterType('username'), 'kuma_user.users.adminlist.filter.username'); |
20
|
|
|
$this->addFilter('email', new StringFilterType('email'), 'kuma_user.users.adminlist.filter.email'); |
21
|
|
|
$this->addFilter('enabled', new BooleanFilterType('enabled'), 'kuma_user.users.adminlist.filter.enabled'); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Configure the visible columns |
26
|
|
|
*/ |
27
|
|
|
public function buildFields() |
28
|
|
|
{ |
29
|
|
|
$this->addField('username', 'kuma_user.users.adminlist.header.username', true); |
30
|
|
|
$this->addField('email', 'kuma_user.users.adminlist.header.email', true); |
31
|
|
|
$this->addField('enabled', 'kuma_user.users.adminlist.header.enabled', true); |
32
|
|
|
$this->addField('lastLogin', 'kuma_user.users.adminlist.header.last_login', false); |
33
|
|
|
$this->addField('groups', 'kuma_user.users.adminlist.header.groups', false); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Override path convention (because settings is a virtual admin subtree) |
38
|
|
|
* |
39
|
|
|
* @param string $suffix |
|
|
|
|
40
|
|
|
* |
41
|
|
|
* @return string |
42
|
|
|
*/ |
43
|
|
|
public function getPathByConvention($suffix = null) |
44
|
|
|
{ |
45
|
|
|
return 'KunstmaanUserManagementBundle_settings_users' . (empty($suffix) ? '' : '_' . $suffix); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Add item actions buttons |
50
|
|
|
*/ |
51
|
|
|
public function buildItemActions() |
52
|
|
|
{ |
53
|
|
|
$this->addItemAction(new UserDeleteItemAction()); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function canDelete($item) |
57
|
|
|
{ |
58
|
|
|
return false; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get entity name |
63
|
|
|
* |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
public function getEntityName() |
67
|
|
|
{ |
68
|
|
|
return 'User'; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.