1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Admin; |
4
|
|
|
|
5
|
|
|
use Sonata\AdminBundle\Admin\Admin; |
6
|
|
|
use Sonata\AdminBundle\Datagrid\ListMapper; |
7
|
|
|
use Sonata\AdminBundle\Datagrid\DatagridMapper; |
8
|
|
|
use Sonata\AdminBundle\Form\FormMapper; |
9
|
|
|
use Sonata\AdminBundle\Route\RouteCollection; |
10
|
|
|
|
11
|
|
|
class PerformanceEventAdmin extends Admin |
12
|
|
|
{ |
13
|
|
|
protected $baseRouteName = 'AppBundle\Entity\PerformanceEvent'; |
14
|
|
|
protected $baseRoutePattern = 'PerformanceEvent'; |
15
|
|
|
protected $datagridValues = [ |
16
|
|
|
'_sort_order' => 'DESC', |
17
|
|
|
'_sort_by' => 'dateTime', |
18
|
|
|
]; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @param RouteCollection $collection |
22
|
|
|
*/ |
23
|
|
|
protected function configureRoutes(RouteCollection $collection) |
24
|
|
|
{ |
25
|
|
|
$collection |
26
|
1 |
|
->add('getVenue') |
27
|
|
|
->add('deletePriceCategories') |
28
|
|
|
; |
29
|
1 |
|
} |
30
|
1 |
|
|
31
|
1 |
|
|
32
|
1 |
|
/** |
33
|
|
|
* @param FormMapper $formMapper |
34
|
1 |
|
* |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
|
|
protected function configureFormFields(FormMapper $formMapper) |
38
|
|
|
{ |
39
|
|
|
$formMapper |
40
|
1 |
|
->with('PerformanceEvents', ['class'=>'col-lg-12']) |
41
|
1 |
|
->add('performance', 'sonata_type_model') |
42
|
1 |
|
->add( |
43
|
|
|
'dateTime', |
44
|
|
|
'sonata_type_datetime_picker', |
45
|
1 |
|
[ |
46
|
|
|
'dp_side_by_side' => true, |
47
|
|
|
'dp_use_current' => false, |
48
|
|
|
'dp_use_seconds' => false, |
49
|
|
|
'format' => "dd/MM/yyyy HH:mm", |
50
|
|
|
] |
51
|
|
|
) |
52
|
2 |
|
->add('venue') |
53
|
|
|
->end() |
54
|
|
|
->with('PriceCategory', [ |
55
|
2 |
|
'class'=>'col-lg-12', |
56
|
2 |
|
]) |
57
|
2 |
|
->add('priceCategories', 'sonata_type_collection', [ |
58
|
2 |
|
'by_reference' => true, |
59
|
|
|
'required' => false, |
60
|
|
|
'cascade_validation' => true, |
61
|
|
|
'type_options' => [ |
62
|
2 |
|
'delete' => true, |
63
|
|
|
], |
64
|
|
|
'label' => false, |
65
|
2 |
|
], [ |
66
|
|
|
'inline' => 'table', |
67
|
|
|
'edit' => 'inline', |
68
|
|
|
'sortable' => 'position', |
69
|
|
|
'link_parameters' => [ |
70
|
|
|
'performanceEvent_id' => $this->getSubject()->getId(), |
71
|
|
|
], |
72
|
2 |
|
]) |
73
|
|
|
->end() |
74
|
|
|
; |
75
|
2 |
|
} |
76
|
2 |
|
|
77
|
2 |
|
/** |
78
|
2 |
|
* @param ListMapper $listMapper |
79
|
2 |
|
* |
80
|
2 |
|
* @return void |
81
|
|
|
*/ |
82
|
2 |
View Code Duplication |
protected function configureListFields(ListMapper $listMapper) |
|
|
|
|
83
|
|
|
{ |
84
|
|
|
$listMapper |
85
|
|
|
->add('performance') |
86
|
|
|
->add('dateTime') |
87
|
|
|
->add('venue') |
88
|
2 |
|
->add('_action', 'actions', [ |
89
|
|
|
'actions' => [ |
90
|
|
|
'edit' => [], |
91
|
|
|
'delete' => [], |
92
|
|
|
], |
93
|
|
|
]) |
94
|
|
|
; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @param DatagridMapper $datagridMapper |
99
|
|
|
* |
100
|
|
|
* @return void |
101
|
|
|
*/ |
102
|
|
|
protected function configureDatagridFilters(DatagridMapper $datagridMapper) |
103
|
|
|
{ |
104
|
|
|
$datagridMapper |
105
|
|
|
->add('performance') |
106
|
|
|
->add('venue') |
107
|
|
|
; |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.