1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Smart\ContentBundle\Admin; |
4
|
|
|
|
5
|
|
|
use Smart\SonataBundle\Admin\AbstractAdmin; |
6
|
|
|
use Sonata\AdminBundle\Datagrid\DatagridMapper; |
7
|
|
|
use Sonata\AdminBundle\Datagrid\ListMapper; |
8
|
|
|
use Sonata\AdminBundle\Form\FormMapper; |
9
|
|
|
use Sonata\AdminBundle\Form\Type\Filter\DateType; |
10
|
|
|
use Sonata\AdminBundle\Show\ShowMapper; |
11
|
|
|
use Sonata\Form\Type\DatePickerType; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Nicolas Bastien <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class PostAdmin extends AbstractAdmin |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* {@inheritdoc} |
20
|
|
|
*/ |
21
|
|
|
public function configureDatagridFilters(DatagridMapper $datagrid) |
22
|
|
|
{ |
23
|
|
|
$datagrid |
24
|
|
|
->add('author', null, [ |
25
|
|
|
'show_filter' => true, |
26
|
|
|
'label' => 'form.label_author' |
27
|
|
|
]) |
28
|
|
|
->add( |
29
|
|
|
'publishedAt', |
30
|
|
|
'doctrine_orm_date', |
31
|
|
|
[ |
32
|
|
|
'label' => 'form.label_published_at' |
33
|
|
|
], |
34
|
|
|
DatePickerType::class, |
35
|
|
|
[ |
36
|
|
|
'format' => 'dd/MM/yyyy', |
37
|
|
|
] |
38
|
|
|
) |
39
|
|
|
; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
|
|
public function configureListFields(ListMapper $list) |
46
|
|
|
{ |
47
|
|
|
$list |
48
|
|
|
->addIdentifier('id') |
49
|
|
|
->add('author', null, ['label' => 'form.label_author']) |
50
|
|
|
->add('category', null, ['label' => 'form.label_category']) |
51
|
|
|
->add('tags', null, ['label' => 'form.label_tags']) |
52
|
|
|
->add('enabled', null, ['label' => 'form.label_enabled']) |
53
|
|
|
->add('publishedAt', 'date', [ |
54
|
|
|
'format' => 'd/m/Y', |
55
|
|
|
'label' => 'form.label_published_at' |
56
|
|
|
]) |
57
|
|
|
; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
|
|
public function configureFormFields(FormMapper $form) |
64
|
|
|
{ |
65
|
|
|
$form |
66
|
|
|
->tab('tab.label_content') |
67
|
|
|
->with('fieldset.label_general') |
68
|
|
|
->end() |
69
|
|
|
->with('fieldset.label_parameters', ['class' => 'col-md-4']) |
70
|
|
|
->add('publishedAt', DatePickerType::class, [ |
71
|
|
|
'required' => false, |
72
|
|
|
'format' => 'dd/MM/yyyy', |
73
|
|
|
]) |
74
|
|
|
->add('author') |
75
|
|
|
->add('category') |
76
|
|
|
->add('tags') |
77
|
|
|
->end() |
78
|
|
|
->end() |
79
|
|
|
; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* {@inheritDoc} |
84
|
|
|
*/ |
85
|
|
|
protected function configureShowFields(ShowMapper $show) |
86
|
|
|
{ |
87
|
|
|
$show |
88
|
|
|
->tab('tab.label_content') |
89
|
|
|
->with('fieldset.label_general') |
90
|
|
|
->end() |
91
|
|
|
->with('fieldset.label_parameters', ['class' => 'col-md-4']) |
92
|
|
|
->add('publishedAt', null, ['label' => 'form.label_published_at']) |
93
|
|
|
->add('author', null, ['label' => 'form.label_author']) |
94
|
|
|
->add('category', null, ['label' => 'form.label_category']) |
95
|
|
|
->add('tags', null, ['label' => 'form.label_tags']) |
96
|
|
|
->end() |
97
|
|
|
->end() |
98
|
|
|
; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|