PlayerBadgeAdmin::configureShowFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 10
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VideoGamesRecords\CoreBundle\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\RouteCollection;
14
use Sonata\AdminBundle\Route\RouteCollectionInterface;
15
use Sonata\AdminBundle\Show\ShowMapper;
16
use Sonata\DoctrineORMAdminBundle\Filter\ModelFilter;
17
use Symfony\Component\Form\Extension\Core\Type\TextType;
18
19
class PlayerBadgeAdmin extends AbstractAdmin
20
{
21
    protected $baseRouteName = 'vgrcorebundle_admin_player_badge';
22
23
    /**
24
     * @param RouteCollection $collection
25
     */
26
    protected function configureRoutes(RouteCollectionInterface $collection): void
27
    {
28
        $collection
29
            ->remove('export');
30
    }
31
32
    /**
33
     * @param FormMapper $form
34
     */
35
    protected function configureFormFields(FormMapper $form): void
36
    {
37
        $form
38
            ->add('id', TextType::class, [
39
                'label' => 'player_badge.form.id',
40
                'attr' => [
41
                    'readonly' => true,
42
                ]
43
            ])
44
            ->add('player', ModelListType::class, [
45
                'btn_add' => false,
46
                'btn_list' => true,
47
                'btn_edit' => false,
48
                'btn_delete' => false,
49
                'btn_catalogue' => false,
50
                'label' => 'player_badge.form.player',
51
            ])
52
            ->add('badge', ModelListType::class, [
53
                'btn_add' => false,
54
                'btn_list' => true,
55
                'btn_edit' => false,
56
                'btn_delete' => false,
57
                'btn_catalogue' => true,
58
                'label' => 'player_badge.form.badge',
59
            ])
60
        ;
61
    }
62
63
    /**
64
     * @param DatagridMapper $filter
65
     */
66
    protected function configureDatagridFilters(DatagridMapper $filter): void
67
    {
68
        $filter
69
            ->add('player', ModelFilter::class, [
70
                'field_type' => ModelAutocompleteType::class,
71
                'field_options' => ['property' => 'pseudo'],
72
                'label' => 'player_badge.filter.player'
73
            ])
74
            ->add('badge.game.libGameFr', null, ['label' => 'player_badge.filter.game.fr'])
75
            ->add('badge.game.libGameEn', null, ['label' => 'player_badge.filter.game.en'])
76
            ->add('badge.value', null, ['label' => 'player_badge.filter.value'])
77
            ->add('badge.type', null, ['label' => 'player_badge.filter.type']);
78
    }
79
80
    /**
81
     * @param ListMapper $list
82
     */
83
    protected function configureListFields(ListMapper $list): void
84
    {
85
        $list
86
            ->addIdentifier('id', null, ['label' => 'player_badge.list.id'])
87
            ->add('player', null, [
88
                'associated_property' => 'pseudo',
89
                'label' => 'player_badge.list.player',
90
            ])
91
            ->add('badge.type', null, [
92
                'label' => 'player_badge.list.type',
93
            ])
94
            ->add('badge.game', null, [
95
                'label' => 'player_badge.list.game',
96
            ])
97
            ->add('badge.country', null, [
98
                'label' => 'player_badge.list.country',
99
            ])
100
            ->add('badge.value', null, [
101
                'label' => 'player_badge.list.value',
102
            ])
103
            ->add('_action', 'actions', [
104
                'actions' => [
105
                    'edit' => [],
106
                    'show' => [],
107
                ]
108
            ]);
109
    }
110
111
    /**
112
     * @param ShowMapper $show
113
     */
114
    protected function configureShowFields(ShowMapper $show): void
115
    {
116
        $show
117
            ->add('id', null, ['label' => 'player_badge.show.id'])
118
            ->add('player', null, ['label' => 'player_badge.show.player'])
119
            ->add('badge', null, ['label' => 'player_badge.show.badge'])
120
            ->add('badge.type', null, ['label' => 'player_badge.show.type'])
121
            ->add('badge.game', null, ['label' => 'player_badge.show.game'])
122
            ->add('badge.country', null, ['label' => 'player_badge.show.country'])
123
            ->add('badge.value', null, ['label' => 'player_badge.show.value']);
124
    }
125
}
126