QueueLogAdmin::configureRoutes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of HeriJobQueueBundle.
5
 *
6
 * (c) Alexandre Mogère
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Heri\Bundle\JobQueueBundle\Admin;
13
14
use Sonata\AdminBundle\Datagrid\DatagridMapper;
15
use Sonata\AdminBundle\Datagrid\ListMapper;
16
use Sonata\AdminBundle\Form\FormMapper;
17
use Sonata\AdminBundle\Route\RouteCollection;
18
use Sonata\AdminBundle\Show\ShowMapper;
19
use Sonata\AdminBundle\Admin\Admin;
20
21
/**
22
 * Class QueueLogAdmin.
23
 */
24
class QueueLogAdmin extends Admin
25
{
26
    use QueueTabMenuTrait;
27
28
    protected $baseRouteName = 'sonata_queue_log';
29
    protected $baseRoutePattern = '/queue_log';
30
31
    protected $translationDomain = 'HeriJobQueueBundle';
32
33
    protected $datagridValues = [
34
        '_sort_order' => 'DESC',
35
        '_sort_by' => 'id',
36
    ];
37
38
    protected $listModes = [
39
        'list' => [
40
            'class' => 'fa fa-list fa-fw',
41
        ],
42
    ];
43
44
    /**
45
     * Fields to be shown on create/edit forms.
46
     *
47
     * @param FormMapper $formMapper
48
     */
49
    protected function configureFormFields(FormMapper $formMapper)
50
    {
51
        // define group zoning
52
        $formMapper
53
            ->with('General', [])->end()
54
        ;
55
56
        $formMapper
57
            ->with('General')
58
            ->add('messageId')
59
            ->add('dateLog', 'sonata_type_datetime_picker', ['dp_side_by_side' => true])
60
            ->add('log')
61
            ->end()
62
        ;
63
    }
64
65
    /**
66
     * Fields to be shown on filter forms.
67
     *
68
     * @param DatagridMapper $datagridMapper
69
     */
70
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
71
    {
72
        $datagridMapper
73
            ->add('messageId')
74
            ->add('dateLog', 'doctrine_orm_datetime_range', ['field_type' => 'sonata_type_datetime_range_picker'])
75
            ->add('log', null, ['global_search' => false])
76
        ;
77
    }
78
79
    /**
80
     * Fields to be shown on lists.
81
     *
82
     * @param ListMapper $listMapper
83
     */
84
    protected function configureListFields(ListMapper $listMapper)
85
    {
86
        $listMapper
87
            ->addIdentifier('id')
88
            ->add('messageId')
89
            ->add('dateLog')
90
            ->add('log')
91
            ->add('_action', 'actions', [
92
                'actions' => [
93
                    'show' => [],
94
                    'edit' => [],
95
                    'delete' => [],
96
                ],
97
            ]);
98
    }
99
100
    protected function configureShowFields(ShowMapper $showMapper)
101
    {
102
        $showMapper
103
            ->add('messageId')
104
            ->add('dateLog')
105
            ->add('log')
106
        ;
107
    }
108
109
    protected function configureRoutes(RouteCollection $collection)
110
    {
111
        $collection
112
            ->remove('create')
113
            ->remove('show')
114
        ;
115
    }
116
}
117