Completed
Push — SF4 ( 4a7883...4059c5 )
by Laurent
07:51
created

UserController::createUserEntityFormBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 21
rs 9.3142
cc 1
eloc 13
nc 1
nop 2
1
<?php
2
3
/**
4
 * AdminController Controller d'administration.
5
 *
6
 * PHP Version 7
7
 *
8
 * @author    Quétier Laurent <[email protected]>
9
 * @copyright 2018 Dev-Int GLSR
10
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
11
 *
12
 * @version GIT: $Id$
13
 *
14
 * @link https://github.com/Dev-Int/glsr
15
 */
16
17
namespace App\Controller;
18
19
use EasyCorp\Bundle\EasyAdminBundle\Controller\AdminController as BaseAdminController;
20
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
21
22
/**
23
 * Admin Controller override EasyAdminBundle::AdminController
24
 *
25
 * @category Controller
26
 */
27
class UserController extends BaseAdminController
28
{
29
    public function createUserEntityFormBuilder($entity, $view)
30
    {
31
        $hierarchy = $this->container->getParameter('security.role_hierarchy.roles');
32
33
        // transform the role hierarchy in a single unique list
34
        $roles = array();
35
        array_walk_recursive($hierarchy, function($role) use (&$roles) {
36
            $roles[$role] = $role;
37
        });
38
39
        $formBuilder = parent::createEntityFormBuilder($entity, $view);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (createEntityFormBuilder() instead of createUserEntityFormBuilder()). Are you sure this is correct? If so, you might want to change this to $this->createEntityFormBuilder().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
40
        $formBuilder->
41
            add('roles', ChoiceType::class,[
42
                'expanded' => true,
43
                'multiple' => true,
44
                'placeholder' => 'Choice a role',
45
                'choices' => $roles,
46
            ]);
47
48
        return $formBuilder;
49
    }
50
}
51