|
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\RouteCollectionInterface; |
|
14
|
|
|
use Sonata\AdminBundle\Show\ShowMapper; |
|
15
|
|
|
use Sonata\DoctrineORMAdminBundle\Filter\ModelFilter; |
|
16
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; |
|
17
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
|
18
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
|
19
|
|
|
use VideoGamesRecords\CoreBundle\ValueObject\VideoType; |
|
20
|
|
|
|
|
21
|
|
|
class VideoAdmin extends AbstractAdmin |
|
22
|
|
|
{ |
|
23
|
|
|
protected $baseRouteName = 'vgrcorebundle_admin_video'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @param RouteCollectionInterface $collection |
|
27
|
|
|
*/ |
|
28
|
|
|
protected function configureRoutes(RouteCollectionInterface $collection): void |
|
29
|
|
|
{ |
|
30
|
|
|
$collection |
|
31
|
|
|
->remove('export') |
|
32
|
|
|
->add('maj', $this->getRouterIdParameter() . '/maj'); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param FormMapper $form |
|
37
|
|
|
*/ |
|
38
|
|
|
protected function configureFormFields(FormMapper $form): void |
|
39
|
|
|
{ |
|
40
|
|
|
$form |
|
41
|
|
|
->add('id', TextType::class, [ |
|
42
|
|
|
'label' => 'video.form.id', |
|
43
|
|
|
'required' => false, |
|
44
|
|
|
'attr' => array( |
|
45
|
|
|
'readonly' => true, |
|
46
|
|
|
) |
|
47
|
|
|
]) |
|
48
|
|
|
->add('player', ModelListType::class, [ |
|
49
|
|
|
'data_class' => null, |
|
50
|
|
|
'btn_add' => false, |
|
51
|
|
|
'btn_list' => true, |
|
52
|
|
|
'btn_edit' => false, |
|
53
|
|
|
'btn_delete' => false, |
|
54
|
|
|
'btn_catalogue' => true, |
|
55
|
|
|
'label' => 'video.form.player', |
|
56
|
|
|
]) |
|
57
|
|
|
->add('game', ModelListType::class, [ |
|
58
|
|
|
'data_class' => null, |
|
59
|
|
|
'btn_add' => false, |
|
60
|
|
|
'btn_list' => true, |
|
61
|
|
|
'btn_edit' => false, |
|
62
|
|
|
'btn_delete' => false, |
|
63
|
|
|
'btn_catalogue' => true, |
|
64
|
|
|
'label' => 'video.form.game', |
|
65
|
|
|
]) |
|
66
|
|
|
->add('title', TextType::class, [ |
|
67
|
|
|
'label' => 'video.form.name', |
|
68
|
|
|
'required' => true, |
|
69
|
|
|
]) |
|
70
|
|
|
->add( |
|
71
|
|
|
'type', |
|
72
|
|
|
ChoiceType::class, |
|
73
|
|
|
[ |
|
74
|
|
|
'label' => 'video.form.type', |
|
75
|
|
|
'choices' => VideoType::getTypeChoices(), |
|
76
|
|
|
'choice_translation_domain' => false, |
|
77
|
|
|
] |
|
78
|
|
|
) |
|
79
|
|
|
->add('url', TextType::class, [ |
|
80
|
|
|
'label' => 'video.form.url', |
|
81
|
|
|
'required' => true, |
|
82
|
|
|
]) |
|
83
|
|
|
->add('isActive', CheckboxType::class, [ |
|
84
|
|
|
'label' => 'video.form.isActive', |
|
85
|
|
|
'required' => false, |
|
86
|
|
|
]); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param DatagridMapper $filter |
|
91
|
|
|
*/ |
|
92
|
|
|
protected function configureDatagridFilters(DatagridMapper $filter): void |
|
93
|
|
|
{ |
|
94
|
|
|
$filter |
|
95
|
|
|
->add('id', null, ['label' => 'video.filter.id']) |
|
96
|
|
|
->add('isActive', null, ['label' => 'video.filter.isActive']) |
|
97
|
|
|
->add('type', null, ['label' => 'video.filter.type']) |
|
98
|
|
|
->add('player', ModelFilter::class, [ |
|
99
|
|
|
'field_type' => ModelAutocompleteType::class, |
|
100
|
|
|
'field_options' => ['property' => 'pseudo'], |
|
101
|
|
|
'label' => 'video.filter.player', |
|
102
|
|
|
]); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @param ListMapper $list |
|
107
|
|
|
*/ |
|
108
|
|
|
protected function configureListFields(ListMapper $list): void |
|
109
|
|
|
{ |
|
110
|
|
|
$list |
|
111
|
|
|
->addIdentifier('id', null, ['label' => 'video.list.id']) |
|
112
|
|
|
->add('player', null, [ |
|
113
|
|
|
'associated_property' => 'pseudo', |
|
114
|
|
|
'label' => 'video.list.player', |
|
115
|
|
|
]) |
|
116
|
|
|
->add('game', null, [ |
|
117
|
|
|
'associated_property' => 'libGameEn', |
|
118
|
|
|
'label' => 'video.list.game', |
|
119
|
|
|
]) |
|
120
|
|
|
->add('title', null, ['label' => 'video.list.title']) |
|
121
|
|
|
->add('type', null, ['label' => 'video.list.type']) |
|
122
|
|
|
->add('externalId', null, ['label' => 'video.list.videoId']) |
|
123
|
|
|
->add( |
|
124
|
|
|
'isActive', |
|
125
|
|
|
'boolean', |
|
126
|
|
|
[ |
|
127
|
|
|
'label' => 'video.list.isActive', |
|
128
|
|
|
'editable' => true, |
|
129
|
|
|
] |
|
130
|
|
|
) |
|
131
|
|
|
->add('_action', 'actions', [ |
|
132
|
|
|
'actions' => [ |
|
133
|
|
|
'show' => [], |
|
134
|
|
|
'edit' => [], |
|
135
|
|
|
'maj' => [ |
|
136
|
|
|
'template' => '@VideoGamesRecordsCore/Admin/object_maj_link.html.twig' |
|
137
|
|
|
], |
|
138
|
|
|
] |
|
139
|
|
|
]); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @param ShowMapper $show |
|
144
|
|
|
*/ |
|
145
|
|
|
protected function configureShowFields(ShowMapper $show): void |
|
146
|
|
|
{ |
|
147
|
|
|
$show->add('id', null, ['label' => 'video.show.id']) |
|
148
|
|
|
->add('isActive', null, ['label' => 'video.show.isActive']) |
|
149
|
|
|
->add('player', null, ['label' => 'video.show.player']) |
|
150
|
|
|
->add('game', null, ['label' => 'video.show.game']) |
|
151
|
|
|
->add('url', null, ['label' => 'video.show.url']) |
|
152
|
|
|
->add('nbComment', null, ['label' => 'video.show.nbComment']) |
|
153
|
|
|
|
|
154
|
|
|
->add('title', null, ['label' => 'video.show.title']) |
|
155
|
|
|
->add('viewCount', null, ['label' => 'video.show.viewCount']) |
|
156
|
|
|
->add('likeCount', null, ['label' => 'video.show.likeCount']) |
|
157
|
|
|
->add('thumbnail', null, ['label' => 'video.show.thumbnail']); |
|
158
|
|
|
} |
|
159
|
|
|
} |
|
160
|
|
|
|