|
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\ModelListType; |
|
12
|
|
|
use Sonata\AdminBundle\Route\RouteCollectionInterface; |
|
13
|
|
|
use Sonata\AdminBundle\Show\ShowMapper; |
|
14
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; |
|
15
|
|
|
|
|
16
|
|
|
class StreamAdmin extends AbstractAdmin |
|
17
|
|
|
{ |
|
18
|
|
|
protected $baseRouteName = 'pn_twitch_admin_stream'; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @param RouteCollectionInterface $collection |
|
22
|
|
|
*/ |
|
23
|
|
|
protected function configureRoutes(RouteCollectionInterface $collection): void |
|
24
|
|
|
{ |
|
25
|
|
|
parent::configureRoutes($collection); |
|
26
|
|
|
$collection |
|
27
|
|
|
->remove('create') |
|
28
|
|
|
; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param FormMapper $form |
|
34
|
|
|
*/ |
|
35
|
|
|
protected function configureFormFields(FormMapper $form): void |
|
36
|
|
|
{ |
|
37
|
|
|
$form |
|
38
|
|
|
->add('title', null, [ |
|
39
|
|
|
'label' => 'label.title', |
|
40
|
|
|
]) |
|
41
|
|
|
->add('game', ModelListType::class, [ |
|
42
|
|
|
'label' => 'label.game', |
|
43
|
|
|
'required' => true, |
|
44
|
|
|
'btn_add' => false, |
|
45
|
|
|
'btn_list' => true, |
|
46
|
|
|
'btn_edit' => false, |
|
47
|
|
|
'btn_delete' => false, |
|
48
|
|
|
]) |
|
49
|
|
|
->add('channel', ModelListType::class, [ |
|
50
|
|
|
'label' => 'label.channel', |
|
51
|
|
|
'required' => true, |
|
52
|
|
|
'btn_add' => false, |
|
53
|
|
|
'btn_list' => true, |
|
54
|
|
|
'btn_edit' => false, |
|
55
|
|
|
'btn_delete' => false, |
|
56
|
|
|
]) |
|
57
|
|
|
->add('type', null, [ |
|
58
|
|
|
'label' => 'label.type', |
|
59
|
|
|
]) |
|
60
|
|
|
->add('language', null, [ |
|
61
|
|
|
'label' => 'label.language', |
|
62
|
|
|
]) |
|
63
|
|
|
->add('isMature', CheckboxType::class, [ |
|
64
|
|
|
'label' => 'label.is_mature', |
|
65
|
|
|
]) |
|
66
|
|
|
; |
|
67
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @param DatagridMapper $filter |
|
72
|
|
|
*/ |
|
73
|
|
|
protected function configureDatagridFilters(DatagridMapper $filter): void |
|
74
|
|
|
{ |
|
75
|
|
|
$filter |
|
76
|
|
|
->add('id', null, ['label' => 'label.id']) |
|
77
|
|
|
->add('title', null, ['label' => 'label.title']) |
|
78
|
|
|
->add('game', null, ['label' => 'label.game']) |
|
79
|
|
|
->add('channel', null, ['label' => 'label.channel']) |
|
80
|
|
|
; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param ListMapper $list |
|
85
|
|
|
*/ |
|
86
|
|
|
protected function configureListFields(ListMapper $list): void |
|
87
|
|
|
{ |
|
88
|
|
|
|
|
89
|
|
|
$list |
|
90
|
|
|
->addIdentifier('id', null, ['label' => 'label.id']) |
|
91
|
|
|
->add('title', null, ['label' => 'label.title', 'editable' => true]) |
|
92
|
|
|
->add('game', null, ['label' => 'label.game']) |
|
93
|
|
|
->add('channel', null, ['label' => 'label.channel']) |
|
94
|
|
|
->add('startedAt', null, ['label' => 'label.started_at']) |
|
95
|
|
|
->add('_action', 'actions', [ |
|
96
|
|
|
'actions' => [ |
|
97
|
|
|
'show' => [], |
|
98
|
|
|
'edit' => [], |
|
99
|
|
|
] |
|
100
|
|
|
]); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @param ShowMapper $show |
|
105
|
|
|
*/ |
|
106
|
|
|
protected function configureShowFields(ShowMapper $show): void |
|
107
|
|
|
{ |
|
108
|
|
|
$show |
|
109
|
|
|
->add('id', null, ['label' => 'label.id']) |
|
110
|
|
|
->add('title', null, ['label' => 'label.title', 'editable' => true]) |
|
111
|
|
|
->add('game', null, ['label' => 'label.game']) |
|
112
|
|
|
->add('channel', null, ['label' => 'label.channel']) |
|
113
|
|
|
->add('startedAt', null, ['label' => 'label.started_at']) |
|
114
|
|
|
->add('isMature', null, ['label' => 'label.is_mature']) |
|
115
|
|
|
->add('tags', null, ['label' => 'label.tags']) |
|
116
|
|
|
; |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|