QueueAdmin   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 101
c 0
b 0
f 0
wmc 6
lcom 0
cbo 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A configureFormFields() 0 15 1
A configureDatagridFilters() 0 9 1
A configureListFields() 0 17 1
A configureShowFields() 0 8 1
A configureRoutes() 0 4 1
A getBatchActions() 0 4 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 QueueAdmin.
23
 */
24
class QueueAdmin extends Admin
25
{
26
    use QueueTabMenuTrait;
27
28
    protected $baseRouteName = 'sonata_queue';
29
    protected $baseRoutePattern = '/queue';
30
31
    protected $translationDomain = 'HeriJobQueueBundle';
32
33
    protected $datagridValues = [
34
        '_sort_order' => 'ASC',
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', ['class' => 'col-md-12'])->end()
54
        ;
55
56
        $formMapper
57
            ->with('General')
58
                ->add('name')
59
                ->add('timeout')
60
                ->add('maxRetries')
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('id')
74
            ->add('name', null, ['global_search' => false])
75
            ->add('timeout')
76
            ->add('maxRetries')
77
        ;
78
    }
79
80
    /**
81
     * Fields to be shown on lists.
82
     *
83
     * @param ListMapper $listMapper
84
     */
85
    protected function configureListFields(ListMapper $listMapper)
86
    {
87
        $listMapper
88
            ->addIdentifier('id')
89
            ->add('name', null, ['editable' => false])
90
            ->add('timeout', null, ['editable' => true])
91
            ->add('maxRetries', null, ['editable' => true])
92
            ->add('_action', 'actions', [
93
                'actions' => [
94
                    'showMessages' => [
95
                        'template' => 'HeriJobQueueBundle:QueueAdmin:showMessages.html.twig',
96
                    ],
97
                    'edit' => [],
98
                    'delete' => [],
99
                ],
100
            ]);
101
    }
102
103
    protected function configureShowFields(ShowMapper $showMapper)
104
    {
105
        $showMapper
106
            ->add('name')
107
            ->add('timeout')
108
            ->add('maxRetries')
109
        ;
110
    }
111
112
    protected function configureRoutes(RouteCollection $collection)
113
    {
114
        $collection->add('showMessages', $this->getRouterIdParameter().'/list');
115
    }
116
117
    /**
118
     * {@inheritdoc}
119
     */
120
    public function getBatchActions()
121
    {
122
        // disable batch action
123
    }
124
}
125