RoleAdmin::configureShowFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 9
ccs 0
cts 6
cp 0
crap 2
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace App\Admin;
4
5
use Sonata\AdminBundle\Admin\AbstractAdmin;
6
use Sonata\AdminBundle\Datagrid\ListMapper;
7
use Sonata\AdminBundle\Datagrid\DatagridMapper;
8
use Sonata\AdminBundle\Form\FormMapper;
9
use Sonata\AdminBundle\Form\Type\ModelType;
10
use Sonata\AdminBundle\Show\ShowMapper;
11
use App\Entity\Role;
12
13
class RoleAdmin extends AbstractAdmin
14
{
15
    protected $baseRouteName = 'App\Entity\Role';
16
    protected $baseRoutePattern = 'Role';
17
    protected $datagridValues = [
18
        '_sort_order' => 'ASC',
19
        '_sort_by'    => 'name',
20
    ];
21
22
    /**
23
     * @param \Sonata\AdminBundle\Show\ShowMapper $showMapper
24
     *
25
     * @return void
26
     */
27
    protected function configureShowFields(ShowMapper $showMapper)
28
    {
29
        $showMapper
30
            ->add('title')
31
            ->add('description')
32
            ->add('performance')
33
            ->add('employee')
34
        ;
35
    }
36
37
    /**
38
     * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
39
     *
40
     * @return void
41
     */
42 2
    protected function configureFormFields(FormMapper $formMapper)
43
    {
44
        $formMapper
45 2
            ->add('title')
46 2
            ->add('description', null, ['required' => false])
47 2
            ->add('employee', ModelType::class, ['required' => false]);
48 2
    }
49
50
    /**
51
     * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
52
     *
53
     * @return void
54
     */
55 2 View Code Duplication
    protected function configureListFields(ListMapper $listMapper)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
56
    {
57
        $listMapper
58 2
            ->addIdentifier('title')
59 2
            ->add('description')
60 2
            ->add('performance')
61 2
            ->add('employee')
62 2
            ->add('_action', 'actions',
63
                [
64
                    'actions' => [
65 2
                        'show' => [],
66
                        'edit' => [],
67
                        'delete' => [],
68
                    ],
69
                ]
70
            )
71
        ;
72 2
    }
73
74
    /**
75
     * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper
76
     *
77
     * @return void
78
     */
79 2
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
80
    {
81
        $datagridMapper
82 2
            ->add('title')
83 2
            ->add('description')
84 2
            ->add('performance')
85 2
            ->add('employee')
86
        ;
87 2
    }
88
}
89