Passed
Push — develop ( 8f1aed...e133e8 )
by BENARD
02:00
created

ChannelAdmin   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A configureListFields() 0 11 1
A configureFormFields() 0 10 1
A configureDatagridFilters() 0 5 1
A configureShowFields() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProjetNormandie\TwitchBundle\Admin;
6
7
use Sonata\AdminBundle\Admin\AbstractAdmin;
8
use Sonata\AdminBundle\Datagrid\DatagridMapper;
9
use Sonata\AdminBundle\Datagrid\ListMapper;
10
use Sonata\AdminBundle\Form\FormMapper;
11
use Sonata\AdminBundle\Form\Type\ModelAutocompleteType;
12
use Sonata\AdminBundle\Form\Type\ModelListType;
13
use Sonata\AdminBundle\Route\RouteCollectionInterface;
14
use Sonata\AdminBundle\Show\ShowMapper;
15
use Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter;
16
use Sonata\DoctrineORMAdminBundle\Filter\ModelFilter;
17
use Sonata\Form\Type\CollectionType;
18
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
19
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
20
use Symfony\Component\Form\Extension\Core\Type\DateType;
21
use Symfony\Component\Form\Extension\Core\Type\TextType;
22
23
24
class ChannelAdmin extends AbstractAdmin
25
{
26
    protected $baseRouteName = 'pn_twitch_admin_channel';
27
28
29
30
31
    /**
32
     * @param FormMapper $form
33
     */
34
    protected function configureFormFields(FormMapper $form): void
35
    {
36
        $form
37
            ->add('name', TextType::class, [
38
                'label' => 'label.name',
39
                'required' => true,
40
            ])
41
            ->add('username', TextType::class, [
42
                'label' => 'label.username',
43
                'required' => true,
44
            ])
45
        ;
46
47
    }
48
49
    /**
50
     * @param DatagridMapper $filter
51
     */
52
    protected function configureDatagridFilters(DatagridMapper $filter): void
53
    {
54
        $filter
55
            ->add('id', null, ['label' => 'label.id'])
56
            ->add('name', null, ['label' => 'label.name'])
57
        ;
58
    }
59
60
    /**
61
     * @param ListMapper $list
62
     */
63
    protected function configureListFields(ListMapper $list): void
64
    {
65
66
        $list
67
            ->addIdentifier('id', null, ['label' => 'label.id'])
68
            ->add('name', null, ['label' => 'label.game', 'editable' => true])
69
            ->add('username', null, ['label' => 'label.username', 'editable' => true])
70
            ->add('_action', 'actions', [
71
                'actions' => [
72
                    'show' => [],
73
                    'edit' => [],
74
                ]
75
            ]);
76
    }
77
78
    /**
79
     * @param ShowMapper $show
80
     */
81
    protected function configureShowFields(ShowMapper $show): void
82
    {
83
        $show
84
            ->add('id', null, ['label' => 'label.id'])
85
            ->add('name', null, ['label' => 'label.name'])
86
            ->add('username', null, ['label' => 'label.username'])
87
        ;
88
    }
89
}
90