Completed
Push — master ( ae412e...33a660 )
by Paweł
13s queued 11s
created

NotificationAdmin::configureFormFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
c 1
b 0
f 1
dl 0
loc 12
rs 9.9666
cc 1
nc 1
nop 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