PerformanceEventAdmin::configureListFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 15
loc 15
ccs 8
cts 8
cp 1
crap 1
rs 9.7666
c 0
b 0
f 0
1
<?php
2
3
namespace App\Admin;
4
5
use Sonata\AdminBundle\Admin\AbstractAdmin;
6
use App\Entity\PerformanceEvent;
7
use Sonata\AdminBundle\Datagrid\ListMapper;
8
use Sonata\AdminBundle\Datagrid\DatagridMapper;
9
use Sonata\AdminBundle\Form\FormMapper;
10
use Sonata\AdminBundle\Form\Type\ModelType;
11
use Sonata\Form\Type\DateTimePickerType;
12
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
13
14
class PerformanceEventAdmin extends AbstractAdmin
15
{
16
    protected $baseRouteName = 'App\Entity\PerformanceEvent';
17
    protected $baseRoutePattern = 'PerformanceEvent';
18
    protected $datagridValues = [
19
        '_sort_order' => 'DESC',
20
        '_sort_by'    => 'dateTime',
21
    ];
22
23
    /**
24
     * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
25
     *
26
     * @return void
27
     */
28 2
    protected function configureFormFields(FormMapper $formMapper)
29
    {
30
        $formMapper
31 2
            ->add('performance', ModelType::class)
32 2
            ->add('dateTime', DateTimePickerType::class,
33
                [
34 2
                    'dp_side_by_side'       => true,
35
                    'dp_use_current'        => false,
36
                    'dp_use_seconds'        => false,
37
                    'format' => "dd/MM/yyyy HH:mm",
38
                ]
39
            )
40 2
            ->add('venue', ChoiceType::class, [
41 2
                'choices'     => PerformanceEvent::$venues,
42 2
                'placeholder' => 'choose_an_option',
43
            ])
44 2
            ->add('buyTicketLink')
45
        ;
46 2
    }
47
48
    /**
49
     * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
50
     *
51
     * @return void
52
     */
53 2 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...
54
    {
55
        $listMapper
56 2
            ->add('performance')
57 2
            ->add('dateTime')
58 2
            ->add('venue', null, ['template' => "App:SonataAdmin:list_field.html.twig"])
59 2
            ->add('buyTicketLink', 'string', ['template' => 'bundles/SonataAdmin/qr_list.html.twig'])
60 2
            ->add('_action', 'actions', [
61
                'actions' => [
62 2
                    'edit' => [],
63
                    'delete' => [],
64
                ],
65
            ])
66
        ;
67 2
    }
68
69
    /**
70
     * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper
71
     *
72
     * @return void
73
     */
74 2
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
75
    {
76
        $datagridMapper
77 2
            ->add('performance')
78 2
            ->add('venue', 'doctrine_orm_choice', [],
79 2
                ChoiceType::class,
80
                [
81 2
                    'choices' => PerformanceEvent::$venues,
82
                    'expanded' => true,
83
                    'multiple' => true
84
                ]
85
            )
86
        ;
87 2
    }
88
}
89