Completed
Pull Request — master (#162)
by
unknown
03:18
created

RoleAdmin::configureListFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 13

Duplication

Lines 18
Ratio 90 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 1
dl 18
loc 20
rs 9.4285
c 0
b 0
f 0
ccs 10
cts 10
cp 1
crap 1
1
<?php
2
3
namespace AppBundle\Admin;
4
5
use Sonata\AdminBundle\Admin\Admin;
6
use Sonata\AdminBundle\Datagrid\ListMapper;
7
use Sonata\AdminBundle\Datagrid\DatagridMapper;
8
use Sonata\AdminBundle\Form\FormMapper;
9
use Sonata\AdminBundle\Show\ShowMapper;
10
use AppBundle\Entity\Role;
11
12
class RoleAdmin extends Admin
13
{
14
    protected $baseRouteName = 'AppBundle\Entity\Role';
15
    protected $baseRoutePattern = 'Role';
16
    protected $datagridValues = [
17
        '_sort_order' => 'ASC',
18
        '_sort_by'    => 'name',
19
    ];
20
21
    /**
22
     * @param \Sonata\AdminBundle\Show\ShowMapper $showMapper
23
     *
24
     * @return void
25
     */
26
    protected function configureShowFields(ShowMapper $showMapper)
27
    {
28
        $showMapper
29
            ->add('title')
30
            ->add('description')
31
            ->add('performance')
32
            ->add('employee')
33
        ;
34
    }
35
36
    /**
37
     * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
38
     *
39
     * @return void
40
     */
41 1
    protected function configureFormFields(FormMapper $formMapper)
42
    {
43
        $formMapper
44 1
            ->add('title')
45 1
            ->add('description', null, ['required' => false])
46 1
            ->add('employee', 'sonata_type_model', ['required' => false]);
47 1
    }
48
49
    /**
50
     * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
51
     *
52
     * @return void
53
     */
54 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...
55
    {
56
        $listMapper
57 2
            ->addIdentifier('title')
58 2
            ->add('description')
59 2
            ->add('performance')
60 2
            ->add('employee')
61 2
            ->add(
62 2
                '_action',
63 2
                'actions',
64
                [
65 2
                    'actions' => [
66
                        'show' => [],
67
                        'edit' => [],
68
                        'delete' => [],
69
                    ],
70
                ]
71
            )
72
        ;
73 2
    }
74
75
    /**
76
     * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper
77
     *
78
     * @return void
79
     */
80 2
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
81
    {
82
        $datagridMapper
83 2
            ->add('title')
84 2
            ->add('description')
85 2
            ->add('performance')
86 2
            ->add('employee')
87
        ;
88 2
    }
89
}
90