Completed
Push — master ( e6c0c9...d841f8 )
by Jeroen
35:52 queued 19:21
created

MenuBundle/AdminList/MenuAdminListConfigurator.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\MenuBundle\AdminList;
4
5
use Doctrine\ORM\EntityManager;
6
use Doctrine\ORM\QueryBuilder;
7
use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper;
8
use Kunstmaan\AdminListBundle\AdminList\Configurator\AbstractDoctrineORMAdminListConfigurator;
9
use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM;
10
11
class MenuAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator
12
{
13
    /**
14
     * @var string
15
     */
16
    private $locale;
17
18
    /**
19
     * @param EntityManager $em        The entity manager
20
     * @param AclHelper     $aclHelper The acl helper
21
     */
22
    public function __construct(EntityManager $em, AclHelper $aclHelper = null)
23
    {
24
        parent::__construct($em, $aclHelper);
25
    }
26
27
    /**
28
     * @param string $locale
29
     */
30
    public function setLocale($locale)
31
    {
32
        $this->locale = $locale;
33
    }
34
35
    /**
36
     * Configure the visible columns
37
     */
38
    public function buildFields()
39
    {
40
        $this->addField('name', 'kuma_menu.menu.adminlist.field.name', true);
0 ignored issues
show
true is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
41
    }
42
43
    /**
44
     * Build filters for admin list
45
     */
46
    public function buildFilters()
47
    {
48
        $this->addFilter('name', new ORM\StringFilterType('name'), 'kuma_menu.menu.adminlist.filter.name');
49
    }
50
51
    /**
52
     * Get bundle name
53
     *
54
     * @return string
55
     */
56
    public function getBundleName()
57
    {
58
        return 'KunstmaanMenuBundle';
59
    }
60
61
    /**
62
     * Get entity name
63
     *
64
     * @return string
65
     */
66
    public function getEntityName()
67
    {
68
        return 'Menu';
69
    }
70
71
    /**
72
     * @return bool
73
     */
74
    public function canAdd()
75
    {
76
        return false;
77
    }
78
79
    /**
80
     * @param object|array $item
81
     *
82
     * @return bool
83
     */
84
    public function canEdit($item)
85
    {
86
        return false;
87
    }
88
89
    /**
90
     * Configure if it's possible to delete the given $item
91
     *
92
     * @param object|array $item
93
     *
94
     * @return bool
95
     */
96
    public function canDelete($item)
97
    {
98
        return false;
99
    }
100
101
    public function adaptQueryBuilder(QueryBuilder $queryBuilder)
102
    {
103
        parent::adaptQueryBuilder($queryBuilder);
104
        $queryBuilder
105
            ->andWhere('b.locale = :locale')
106
            ->setParameter('locale', $this->locale);
107
    }
108
}
109