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
|
|
|
|