NotificationAdmin::configureListFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 14
c 1
b 0
f 1
dl 0
loc 16
rs 9.7998
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('urlTitle')
38
            ->add('label')
39
            ->add('created')
40
            ->add('updated')
41
            ->add('_action', null, [
42
                'actions' => [
43
                    'show' => [],
44
                    'edit' => [],
45
                    'delete' => [],
46
                ],
47
            ]);
48
    }
49
50
    protected function configureFormFields(FormMapper $formMapper): void
51
    {
52
        $formMapper
53
            ->add('title')
54
            ->add('text')
55
            ->add('url')
56
            ->add('urlTitle')
57
            ->add('label', ChoiceType::class, [
58
                    'choices' => [
59
                        'New' => NotificationInterface::LABEL_NEW,
60
                        'Important' => NotificationInterface::LABEL_IMPORTANT,
61
                    ],
62
                    'required' => true,
63
                ]
64
            )
65
            ;
66
    }
67
68
    protected function configureShowFields(ShowMapper $showMapper): void
69
    {
70
        $showMapper
71
            ->add('id')
72
            ->add('title')
73
            ->add('text')
74
            ->add('url')
75
            ->add('urlTitle')
76
            ->add('label')
77
            ->add('created')
78
            ->add('updated')
79
            ;
80
    }
81
}
82