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\Route\RouteCollectionInterface; |
12
|
|
|
use Sonata\AdminBundle\Show\ShowMapper; |
13
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
14
|
|
|
|
15
|
|
|
class GameAdmin extends AbstractAdmin |
16
|
|
|
{ |
17
|
|
|
protected $baseRouteName = 'pn_twitch_admin_game'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @param RouteCollectionInterface $collection |
21
|
|
|
*/ |
22
|
|
|
protected function configureRoutes(RouteCollectionInterface $collection): void |
23
|
|
|
{ |
24
|
|
|
parent::configureRoutes($collection); |
25
|
|
|
$collection |
26
|
|
|
->remove('create') |
27
|
|
|
->remove('delete') |
28
|
|
|
; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param FormMapper $form |
34
|
|
|
*/ |
35
|
|
|
protected function configureFormFields(FormMapper $form): void |
36
|
|
|
{ |
37
|
|
|
$form |
38
|
|
|
->add('name', TextType::class, [ |
39
|
|
|
'label' => 'label.name', |
40
|
|
|
'required' => true, |
41
|
|
|
]) |
42
|
|
|
->add('picture', TextType::class, [ |
43
|
|
|
'label' => 'label.picture', |
44
|
|
|
'required' => false, |
45
|
|
|
]) |
46
|
|
|
->add('url', TextType::class, [ |
47
|
|
|
'label' => 'label.url', |
48
|
|
|
'required' => false, |
49
|
|
|
]) |
50
|
|
|
; |
51
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param DatagridMapper $filter |
56
|
|
|
*/ |
57
|
|
|
protected function configureDatagridFilters(DatagridMapper $filter): void |
58
|
|
|
{ |
59
|
|
|
$filter |
60
|
|
|
->add('id', null, ['label' => 'label.id']) |
61
|
|
|
->add('name', null, ['label' => 'label.name']) |
62
|
|
|
->add('picture', null, ['label' => 'label.picture']) |
63
|
|
|
->add('url', null, ['label' => 'label.url']) |
64
|
|
|
; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param ListMapper $list |
69
|
|
|
*/ |
70
|
|
|
protected function configureListFields(ListMapper $list): void |
71
|
|
|
{ |
72
|
|
|
|
73
|
|
|
$list |
74
|
|
|
->addIdentifier('id', null, ['label' => 'label.id']) |
75
|
|
|
->add('name', null, ['label' => 'label.name', 'editable' => true]) |
76
|
|
|
->add('picture', null, ['label' => 'label.picture', 'editable' => true]) |
77
|
|
|
->add('url', null, ['label' => 'label.url', 'editable' => true]) |
78
|
|
|
->add('_action', 'actions', [ |
79
|
|
|
'actions' => [ |
80
|
|
|
'show' => [], |
81
|
|
|
'edit' => [], |
82
|
|
|
] |
83
|
|
|
]); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param ShowMapper $show |
88
|
|
|
*/ |
89
|
|
|
protected function configureShowFields(ShowMapper $show): void |
90
|
|
|
{ |
91
|
|
|
$show |
92
|
|
|
->add('id', null, ['label' => 'label.id']) |
93
|
|
|
->add('name', null, ['label' => 'label.name']) |
94
|
|
|
->add('picture', null, ['label' => 'label.picture']) |
95
|
|
|
->add('url', null, ['label' => 'label.url']) |
96
|
|
|
; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|