Completed
Push — 2.x-dev-kit ( 8d77e1 )
by
unknown
28:22 queued 25:50
created

MessageAdmin   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 6
dl 0
loc 79
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A configureShowFields() 0 13 1
A configureRoutes() 0 8 1
A configureListFields() 0 12 1
A configureDatagridFilters() 0 9 1
A getBatchActions() 0 15 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata project.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\NotificationBundle\Admin;
13
14
use Sonata\AdminBundle\Admin\Admin;
15
use Sonata\AdminBundle\Datagrid\DatagridMapper;
16
use Sonata\AdminBundle\Datagrid\ListMapper;
17
use Sonata\AdminBundle\Route\RouteCollection;
18
use Sonata\AdminBundle\Show\ShowMapper;
19
20
class MessageAdmin extends Admin
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function configureShowFields(ShowMapper $showMapper)
26
    {
27
        $showMapper
28
            ->add('id')
29
            ->add('type')
30
            ->add('createdAt')
31
            ->add('startedAt')
32
            ->add('completedAt')
33
            ->add('getStateName')
34
            ->add('body')
35
            ->add('restartCount')
36
        ;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function configureRoutes(RouteCollection $collection)
43
    {
44
        $collection
45
            ->remove('edit')
46
            ->remove('create')
47
            ->remove('history')
48
        ;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    protected function configureListFields(ListMapper $listMapper)
55
    {
56
        $listMapper
57
            ->addIdentifier('id', null, array('route' => array('name' => 'show')))
58
            ->add('type')
59
            ->add('createdAt')
60
            ->add('startedAt')
61
            ->add('completedAt')
62
            ->add('getStateName')
63
            ->add('restartCount')
64
        ;
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
71
    {
72
        $class = $this->getClass();
73
74
        $datagridMapper
75
            ->add('type')
76
            ->add('state', null, array(), 'choice', array('choices' => $class::getStateList()))
77
        ;
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     */
83
    public function getBatchActions()
84
    {
85
        $actions = array();
86
        $actions['publish'] = array(
87
            'label'            => $this->trans($this->getLabelTranslatorStrategy()->getLabel('publish', 'batch', 'message')),
88
            'ask_confirmation' => false,
89
        );
90
91
        $actions['cancelled'] = array(
92
            'label'            => $this->trans($this->getLabelTranslatorStrategy()->getLabel('cancelled', 'batch', 'message')),
93
            'ask_confirmation' => false,
94
        );
95
96
        return $actions;
97
    }
98
}
99