ChannelAdmin::configureShowFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 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\Show\ShowMapper;
12
use Symfony\Component\Form\Extension\Core\Type\TextType;
13
14
class ChannelAdmin extends AbstractAdmin
15
{
16
    protected $baseRouteName = 'pn_twitch_admin_channel';
17
18
19
    /**
20
     * @param FormMapper $form
21
     */
22
    protected function configureFormFields(FormMapper $form): void
23
    {
24
        $form
25
            ->add('name', TextType::class, [
26
                'label' => 'label.name',
27
                'required' => true,
28
            ])
29
            ->add('username', TextType::class, [
30
                'label' => 'label.username',
31
                'required' => true,
32
            ])
33
            ->add('isCommunity', null, [
34
                'label' => 'label.is_community',
35
            ])
36
        ;
37
38
    }
39
40
    /**
41
     * @param DatagridMapper $filter
42
     */
43
    protected function configureDatagridFilters(DatagridMapper $filter): void
44
    {
45
        $filter
46
            ->add('id', null, ['label' => 'label.id'])
47
            ->add('name', null, ['label' => 'label.name'])
48
            ->add('isCommunity', null, ['label' => 'label.is_community'])
49
        ;
50
    }
51
52
    /**
53
     * @param ListMapper $list
54
     */
55
    protected function configureListFields(ListMapper $list): void
56
    {
57
58
        $list
59
            ->addIdentifier('id', null, ['label' => 'label.id'])
60
            ->add('name', null, ['label' => 'label.game', 'editable' => true])
61
            ->add('username', null, ['label' => 'label.username', 'editable' => true])
62
            ->add('isCommunity', null, ['label' => 'label.is_community'])
63
            ->add('_action', 'actions', [
64
                'actions' => [
65
                    'show' => [],
66
                    'edit' => [],
67
                ]
68
            ]);
69
    }
70
71
    /**
72
     * @param ShowMapper $show
73
     */
74
    protected function configureShowFields(ShowMapper $show): void
75
    {
76
        $show
77
            ->add('id', null, ['label' => 'label.id'])
78
            ->add('name', null, ['label' => 'label.name'])
79
            ->add('username', null, ['label' => 'label.username'])
80
            ->add('isCommunity', null, ['label' => 'label.is_community'])
81
        ;
82
    }
83
}
84