Completed
Pull Request — master (#136)
by
unknown
12:44
created

PerformanceEventAdmin::configureFormFields()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 38
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 28
nc 1
nop 1
dl 0
loc 38
ccs 12
cts 12
cp 1
crap 1
rs 8.8571
c 0
b 0
f 0
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('setNumber')
53
            ->add('venue')
54
            ->end()
55 2
            ->with('PriceCategory', ['class'=>'col-lg-12'])
56 2
            ->add('priceCategories', 'sonata_type_collection', [
57 2
                'by_reference' => true,
58 2
                'required' => false,
59
                'cascade_validation' => true,
60
                'type_options'       => [
61
                    'delete' => true,
62 2
                ],
63
                'label' => false,
64
            ], [
65 2
                'inline'            => 'table',
66
                'edit'            => 'inline',
67
                'sortable'        => 'position',
68
                'link_parameters'       => [
69
                    'performanceEvent_id' => $this->getSubject()->getId(),
70
                ],
71
            ])
72 2
            ->end()
73
        ;
74
    }
75 2
76 2
    /**
77 2
     * @param ListMapper $listMapper
78 2
     *
79 2
     * @return void
80 2
     */
81 View Code Duplication
    protected function configureListFields(ListMapper $listMapper)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
82 2
    {
83
        $listMapper
84
            ->add('performance')
85
            ->add('dateTime')
86
            ->add('venue')
87
            ->add('_action', 'actions', [
88 2
                'actions' => [
89
                    'edit' => [],
90
                    'delete' => [],
91
                ],
92
            ])
93
        ;
94
    }
95
96
    /**
97
     * @param DatagridMapper $datagridMapper
98
     *
99
     * @return void
100
     */
101
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
102
    {
103
        $datagridMapper
104
            ->add('performance')
105
            ->add('venue')
106
        ;
107
    }
108
}
109