Completed
Push — master ( c37a1b...043479 )
by Serhii
11s
created

PriceCategoryAdmin::toString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 6
rs 9.4285
1
<?php
2
3
namespace AppBundle\Admin;
4
5
use AppBundle\Entity\PriceCategory;
6
use Sonata\AdminBundle\Admin\Admin;
7
use Sonata\AdminBundle\Datagrid\ListMapper;
8
use Sonata\AdminBundle\Datagrid\DatagridMapper;
9
use Sonata\AdminBundle\Form\FormMapper;
10
11
class PriceCategoryAdmin extends Admin
12
{
13
    protected $baseRouteName = 'AppBundle\Entity\PriceCategory';
14
    protected $baseRoutePattern = 'PriceCategory';
15
    protected $datagridValues = [
16
        '_sort_order' => 'DESC',
17
        '_sort_by'    => 'venue',
18
    ];
19
20
    /**
21
     * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
22
     *
23
     * @return void
24
     */
25
    protected function configureFormFields(FormMapper $formMapper)
26
    {
27
        $formMapper
28
            ->add('title')
29
            ->add('color', 'sonata_type_color_selector')
30
            ->add('venue')
31
        ;
32
    }
33
34
    /**
35
     * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
36
     *
37
     * @return void
38
     */
39 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...
40
    {
41
        $listMapper
42
            ->add('venue')
43
            ->add('_action', 'actions', [
44
                'actions' => [
45
                    'edit' => [],
46
                    'delete' => [],
47
                ],
48
            ])
49
        ;
50
    }
51
52
    /**
53
     * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper
54
     *
55
     * @return void
56
     */
57
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
58
    {
59
        $datagridMapper
60
            ->add('venue')
61
        ;
62
    }
63
64
    public function toString($object)
65
    {
66
        return $object instanceof PriceCategory
67
            ? $object->getTitle()
68
            : 'PriceCategory'; // shown in the breadcrumb on the create views
69
    }
70
}
71