Completed
Pull Request — 3.x (#202)
by
unknown
16:06 queued 13:05
created

MessageAdmin::configureRoutes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
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
0 ignored issues
show
Deprecated Code introduced by
The class Sonata\AdminBundle\Admin\Admin has been deprecated with message: since version 3.1, to be removed in 4.0. Use Sonata\AdminBundle\AbstractAdmin instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function configureRoutes(RouteCollection $collection)
26
    {
27
        $collection
28
            ->remove('edit')
29
            ->remove('create')
30
            ->remove('history')
31
        ;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function getBatchActions()
38
    {
39
        $actions = array();
40
        $actions['publish'] = array(
41
            'label' => $this->trans($this->getLabelTranslatorStrategy()->getLabel('publish', 'batch', 'message')),
42
            'ask_confirmation' => false,
43
        );
44
45
        $actions['cancelled'] = array(
46
            'label' => $this->trans($this->getLabelTranslatorStrategy()->getLabel('cancelled', 'batch', 'message')),
47
            'ask_confirmation' => false,
48
        );
49
50
        return $actions;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    protected function configureShowFields(ShowMapper $showMapper)
57
    {
58
        $showMapper
59
            ->add('id')
60
            ->add('type')
61
            ->add('createdAt')
62
            ->add('startedAt')
63
            ->add('completedAt')
64
            ->add('getStateName')
65
            ->add('body')
66
            ->add('restartCount')
67
        ;
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73
    protected function configureListFields(ListMapper $listMapper)
74
    {
75
        $listMapper
76
            ->addIdentifier('id', null, array('route' => array('name' => 'show')))
77
            ->add('type')
78
            ->add('createdAt')
79
            ->add('startedAt')
80
            ->add('completedAt')
81
            ->add('getStateName')
82
            ->add('restartCount')
83
        ;
84
    }
85
86
    /**
87
     * {@inheritdoc}
88
     */
89
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
90
    {
91
        $class = $this->getClass();
92
93
        $datagridMapper
94
            ->add('type')
95
            ->add('state', null, array(), 'choice', array('choices' => $class::getStateList()))
96
        ;
97
    }
98
}
99