Completed
Push — master ( 947afa...ae5e03 )
by Jeroen
26s queued 14s
created

UserAdminListConfigurator::canDelete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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
0 ignored issues
show
Documentation introduced by
Should the type for parameter $suffix not be string|null?

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.

Loading history...
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