Passed
Pull Request — master (#45)
by Paweł
03:25
created

NotificationAdmin   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 39
c 1
b 0
f 1
dl 0
loc 61
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A configureDatagridFilters() 0 10 1
A configureShowFields() 0 10 1
A configureFormFields() 0 12 1
A configureListFields() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Admin;
6
7
use App\Model\NotificationInterface;
8
use Sonata\AdminBundle\Admin\AbstractAdmin;
9
use Sonata\AdminBundle\Datagrid\DatagridMapper;
10
use Sonata\AdminBundle\Datagrid\ListMapper;
11
use Sonata\AdminBundle\Form\FormMapper;
12
use Sonata\AdminBundle\Show\ShowMapper;
13
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
14
15
final class NotificationAdmin extends AbstractAdmin
16
{
17
    protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
18
    {
19
        $datagridMapper
20
            ->add('id')
21
            ->add('title')
22
            ->add('text')
23
            ->add('url')
24
            ->add('label')
25
            ->add('created')
26
            ->add('updated')
27
            ;
28
    }
29
30
    protected function configureListFields(ListMapper $listMapper): void
31
    {
32
        $listMapper
33
            ->add('id')
34
            ->add('title')
35
            ->add('text')
36
            ->add('url')
37
            ->add('label')
38
            ->add('created')
39
            ->add('updated')
40
            ->add('_action', null, [
41
                'actions' => [
42
                    'show' => [],
43
                    'edit' => [],
44
                    'delete' => [],
45
                ],
46
            ]);
47
    }
48
49
    protected function configureFormFields(FormMapper $formMapper): void
50
    {
51
        $formMapper
52
            ->add('title')
53
            ->add('text')
54
            ->add('url')
55
            ->add('label', ChoiceType::class, [
56
                    'choices' => [
57
                        'New' => NotificationInterface::LABEL_NEW,
58
                        'Important' => NotificationInterface::LABEL_IMPORTANT,
59
                    ],
60
                    'required' => true,
61
                ]
62
            )
63
            ;
64
    }
65
66
    protected function configureShowFields(ShowMapper $showMapper): void
67
    {
68
        $showMapper
69
            ->add('id')
70
            ->add('title')
71
            ->add('text')
72
            ->add('url')
73
            ->add('label')
74
            ->add('created')
75
            ->add('updated')
76
            ;
77
    }
78
}
79