CategoryAdmin::configureRoutes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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\Route\RouteCollectionInterface;
9
use Sonata\AdminBundle\Show\ShowMapper;
10
use Sonata\AdminBundle\Form\FormMapper;
11
use Sonata\AdminBundle\Datagrid\ListMapper;
12
use Sonata\AdminBundle\Datagrid\DatagridMapper;
13
use Sonata\AdminBundle\Route\RouteCollection;
14
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
15
use Symfony\Component\Form\Extension\Core\Type\TextType;
16
17
/**
18
 * Administration manager for the Forum Bundle.
19
 */
20
class CategoryAdmin extends AbstractAdmin
21
{
22
    protected $baseRouteName = 'pnf_admin_category';
23
24
    /**
25
     * @param RouteCollection $collection
26
     */
27
    protected function configureRoutes(RouteCollectionInterface $collection): void
28
    {
29
        $collection->remove('export');
30
    }
31
32
    /**
33
     * @param FormMapper $form
34
     */
35
    protected function configureFormFields(FormMapper $form): void
36
    {
37
        $form->add('id', TextType::class, ['label' => 'label.id', 'attr' => ['readonly' => true]])
38
            ->add('name', TextType::class, ['label' => 'label.name'])
39
            ->add('position', TextType::class, ['label' => 'label.position', 'required' => false])
40
            ->add('displayOnHome', CheckboxType::class, [
41
                'label' => 'label.displayOnHome',
42
                'required' => false
43
            ]);
44
    }
45
46
    /**
47
     * @param DatagridMapper $filter
48
     */
49
    protected function configureDatagridFilters(DatagridMapper $filter): void
50
    {
51
        $filter
52
            ->add('name', null, ['label' => 'label.name'])
53
            ->add('displayOnHome', null, ['label' => 'label.displayOnHome']);
54
    }
55
56
    /**
57
     * @param ListMapper $list
58
     */
59
    protected function configureListFields(ListMapper $list): void
60
    {
61
        $list->addIdentifier('id', null, ['label' => 'label.id'])
62
            ->add('name', null, ['label' => 'label.name'])
63
            ->add('position', null, ['label' => 'label.position'])
64
            ->add('displayOnHome', null, [
65
                'label' => 'label.displayOnHome',
66
                'editable' => true
67
            ])
68
            ->add('_action', 'actions', ['actions' => ['show' => [], 'edit' => []]]);
69
    }
70
71
    /**
72
     * @param ShowMapper $show
73
     */
74
    protected function configureShowFields(ShowMapper $show): void
75
    {
76
        $show->add('id', null, ['label' => 'label.id'])
77
            ->add('name', null, ['label' => 'label.name'])
78
            ->add('position', null, ['label' => 'label.position'])
79
            ->add('displayOnHome', null, ['label' => 'label.displayOnHome']);
80
    }
81
}
82