1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace ProjetNormandie\ForumBundle\Admin; |
6
|
|
|
|
7
|
|
|
use Sonata\AdminBundle\Admin\AbstractAdmin; |
8
|
|
|
use Sonata\AdminBundle\Form\Type\ModelAutocompleteType; |
9
|
|
|
use Sonata\AdminBundle\Route\RouteCollectionInterface; |
10
|
|
|
use Sonata\AdminBundle\Show\ShowMapper; |
11
|
|
|
use Sonata\AdminBundle\Form\FormMapper; |
12
|
|
|
use Sonata\AdminBundle\Datagrid\ListMapper; |
13
|
|
|
use Sonata\AdminBundle\Datagrid\DatagridMapper; |
14
|
|
|
use Sonata\AdminBundle\Route\RouteCollection; |
15
|
|
|
use Sonata\DoctrineORMAdminBundle\Filter\ModelFilter; |
16
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Administration manager for the Forum Bundle. |
20
|
|
|
*/ |
21
|
|
|
class TopicAdmin extends AbstractAdmin |
22
|
|
|
{ |
23
|
|
|
protected $baseRouteName = 'pnf_admin_topic'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param RouteCollection $collection |
27
|
|
|
*/ |
28
|
|
|
protected function configureRoutes(RouteCollectionInterface $collection): void |
29
|
|
|
{ |
30
|
|
|
$collection->remove('export') |
31
|
|
|
->remove('create'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param FormMapper $form |
36
|
|
|
*/ |
37
|
|
|
protected function configureFormFields(FormMapper $form): void |
38
|
|
|
{ |
39
|
|
|
$form->add('id', TextType::class, ['label' => 'label.id', 'attr' => ['readonly' => true]]) |
40
|
|
|
->add('name', TextType::class, ['label' => 'label.name']) |
41
|
|
|
->add('boolArchive') |
42
|
|
|
->add('forum') |
43
|
|
|
->add('type'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param DatagridMapper $filter |
48
|
|
|
*/ |
49
|
|
|
protected function configureDatagridFilters(DatagridMapper $filter): void |
50
|
|
|
{ |
51
|
|
|
$filter |
52
|
|
|
->add('id', null, ['label' => 'label.id']) |
53
|
|
|
->add('name', null, ['label' => 'label.name']) |
54
|
|
|
->add('forum', ModelFilter::class, [ |
55
|
|
|
'field_type' => ModelAutocompleteType::class, |
56
|
|
|
'field_options' => ['property' => 'libForum'], |
57
|
|
|
'label' => 'label.forum', |
58
|
|
|
]) |
59
|
|
|
->add('boolArchive', null, ['label' => 'label.boolArchive']); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param ListMapper $list |
64
|
|
|
*/ |
65
|
|
|
protected function configureListFields(ListMapper $list): void |
66
|
|
|
{ |
67
|
|
|
$list->addIdentifier('id', null, ['label' => 'label.id']) |
68
|
|
|
->add('name', null, ['label' => 'label.name']) |
69
|
|
|
->add('type', null, ['label' => 'label.type']) |
70
|
|
|
->add( |
71
|
|
|
'boolArchive', |
72
|
|
|
null, |
73
|
|
|
[ |
74
|
|
|
'label' => 'label.boolArchive', |
75
|
|
|
'editable' => true, |
76
|
|
|
] |
77
|
|
|
) |
78
|
|
|
->add('forum', null, ['label' => 'label.forum']) |
79
|
|
|
->add('user', null, ['label' => 'label.user']) |
80
|
|
|
->add('_action', 'actions', ['actions' => ['show' => [], 'edit' => []]]); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param ShowMapper $show |
85
|
|
|
*/ |
86
|
|
|
protected function configureShowFields(ShowMapper $show): void |
87
|
|
|
{ |
88
|
|
|
$show->add('id', null, ['label' => 'label.id']) |
89
|
|
|
->add('name', null, ['label' => 'label.name']) |
90
|
|
|
->add('type', null, ['label' => 'label.type']) |
91
|
|
|
->add('boolArchive', null, ['label' => 'label.boolArchive']) |
92
|
|
|
->add('nbMessage', null, ['label' => 'label.nbMessage']) |
93
|
|
|
->add('lastMessage', null, ['label' => 'label.lastMessage']) |
94
|
|
|
->add('forum', null, ['label' => 'label.forum']) |
95
|
|
|
->add('user', null, ['label' => 'label.user']) |
96
|
|
|
->add('messages', null, ['label' => 'label.messages']); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|