|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PiedWeb\ConversationBundle\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use Sonata\AdminBundle\Admin\AbstractAdmin; |
|
6
|
|
|
use Sonata\AdminBundle\Datagrid\DatagridMapper; |
|
7
|
|
|
use Sonata\AdminBundle\Datagrid\ListMapper; |
|
8
|
|
|
use Sonata\AdminBundle\Form\FormMapper; |
|
9
|
|
|
use Sonata\Form\Type\DateTimePickerType; |
|
10
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType; |
|
11
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
|
12
|
|
|
|
|
13
|
|
|
class ConversationAdmin extends AbstractAdmin |
|
14
|
|
|
{ |
|
15
|
|
|
protected $datagridValues = [ |
|
16
|
|
|
'_page' => 1, |
|
17
|
|
|
'_sort_order' => 'DESC', |
|
18
|
|
|
'_sort_by' => 'createdAt', |
|
19
|
|
|
'_per_page' => 256, |
|
20
|
|
|
]; |
|
21
|
|
|
|
|
22
|
|
|
protected function configureFormFields(FormMapper $formMapper) |
|
23
|
|
|
{ |
|
24
|
|
|
$formMapper->with('admin.conversation.label.conversation', ['class' => 'col-md-8']) |
|
25
|
|
|
->add('content', TextareaType::class, [ |
|
26
|
|
|
'attr' => ['rows' => 6], |
|
27
|
|
|
'label' => 'admin.conversation.content.label', |
|
28
|
|
|
]) |
|
29
|
|
|
->add('referring', TextType::class, [ |
|
30
|
|
|
'label' => 'admin.conversation.referring.label', |
|
31
|
|
|
]) |
|
32
|
|
|
->add('createdAt', DateTimePickerType::class, [ |
|
33
|
|
|
'label' => 'admin.conversation.createdAt.label', |
|
34
|
|
|
]) |
|
35
|
|
|
->end(); |
|
36
|
|
|
|
|
37
|
|
|
$formMapper->with('admin.conversation.label.author', ['class' => 'col-md-4']) |
|
38
|
|
|
->add('authorEmail', null, [ |
|
39
|
|
|
'label' => 'admin.conversation.authorEmail.label', |
|
40
|
|
|
]) |
|
41
|
|
|
->add('authorName', null, [ |
|
42
|
|
|
'required' => false, |
|
43
|
|
|
'label' => 'admin.conversation.authorName.label', |
|
44
|
|
|
]) |
|
45
|
|
|
->add('authorIp', null, [ |
|
46
|
|
|
'required' => false, |
|
47
|
|
|
'label' => 'admin.conversation.authorIp.label', |
|
48
|
|
|
'attr' => [ |
|
49
|
|
|
($this->getSubject() ? ($this->getSubject()->getAuthorIp() ? 'disabled' : 't') : 't') => '', |
|
50
|
|
|
], |
|
51
|
|
|
]) |
|
52
|
|
|
->end(); |
|
53
|
|
|
|
|
54
|
|
|
$formMapper->with('admin.conversation.label.publishedAt', ['class' => 'col-md-4']) |
|
55
|
|
|
->add('publishedAt', DateTimePickerType::class, [ |
|
56
|
|
|
'required' => false, |
|
57
|
|
|
'label' => '', |
|
58
|
|
|
]) |
|
59
|
|
|
->end(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
protected function configureDatagridFilters(DatagridMapper $datagridMapper) |
|
63
|
|
|
{ |
|
64
|
|
|
$datagridMapper->add('referring', null, [ |
|
65
|
|
|
'label' => 'admin.conversation.from.label', |
|
66
|
|
|
]); |
|
67
|
|
|
$datagridMapper->add('authorEmail', null, [ |
|
68
|
|
|
'label' => 'admin.conversation.authorEmail.label', |
|
69
|
|
|
]); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
protected function configureListFields(ListMapper $listMapper) |
|
73
|
|
|
{ |
|
74
|
|
|
$listMapper |
|
75
|
|
|
->add('referring', TextType::class) |
|
76
|
|
|
->addIdentifier('content') |
|
77
|
|
|
->add('authorEmail') |
|
78
|
|
|
->add('authorName') |
|
79
|
|
|
->add('authorIpRaw') |
|
80
|
|
|
->add('createdAt') |
|
81
|
|
|
->add('publishedAt'); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|