GroupAdmin   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 27
c 0
b 0
f 0
dl 0
loc 59
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A configureDatagridFilters() 0 4 1
A configureFormFields() 0 12 1
A configureListFields() 0 10 1
A configureShowFields() 0 8 1
1
<?php
2
3
namespace ProjetNormandie\UserBundle\Admin;
4
5
use Sonata\AdminBundle\Admin\AbstractAdmin;
6
use Sonata\AdminBundle\Datagrid\DatagridMapper;
7
use Sonata\AdminBundle\Datagrid\ListMapper;
8
use Sonata\AdminBundle\Form\FormMapper;
9
use Sonata\AdminBundle\Show\ShowMapper;
10
use Symfony\Component\Form\Extension\Core\Type\TextType;
11
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
12
13
class GroupAdmin extends AbstractAdmin
14
{
15
    protected $baseRouteName = 'pnu_admin_group';
16
17
    /**
18
     * @param FormMapper $form
19
     */
20
    protected function configureFormFields(FormMapper $form): void
21
    {
22
        $form
23
            ->add('name', TextType::class, [
24
                'label' => 'group.form.name',
25
                'required' => false,
26
            ])
27
            ->add('roles', CollectionType::class, [
28
                'label' => 'group.form.roles',
29
                'required' => false,
30
                'allow_add' => true,
31
                'allow_delete' => true,
32
            ]);
33
    }
34
35
    /**
36
     * @param DatagridMapper $filter
37
     */
38
    protected function configureDatagridFilters(DatagridMapper $filter): void
39
    {
40
        $filter
41
            ->add('name', null, ['label' => 'group.filter.name']);
42
    }
43
44
    /**
45
     * @param ListMapper $list
46
     */
47
    protected function configureListFields(ListMapper $list): void
48
    {
49
        $list
50
            ->addIdentifier('id', null, ['label' => 'group.list.id'])
51
            ->add('name', null, ['label' => 'group.list.name'])
52
            ->add('roles', null, ['label' => 'group.list.roles'])
53
            ->add('_action', 'actions', [
54
                'actions' => [
55
                    'show' => [],
56
                    'edit' => [],
57
                ]
58
            ]);
59
    }
60
61
    /**
62
     * @param ShowMapper $show
63
     */
64
    protected function configureShowFields(ShowMapper $show): void
65
    {
66
        $show
67
            ->with('group_show_group', ['class' => 'col-md-12'])
68
            ->add('id', null, ['label' => 'group.show.id'])
69
            ->add('name', null, ['label' => 'group.show.name'])
70
            ->add('roles', null, ['label' => 'group.show.roles'])
71
            ->end();
72
    }
73
}
74