Issues (5)

src/Admin/PageAdmin.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProjetNormandie\PageBundle\Admin;
6
7
use A2lix\TranslationFormBundle\Form\Type\TranslationsType;
8
use ProjetNormandie\PageBundle\Form\Type\RichTextEditorType;
9
use ProjetNormandie\PageBundle\ValueObject\PageStatus;
0 ignored issues
show
The type ProjetNormandie\PageBundle\ValueObject\PageStatus was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Sonata\AdminBundle\Admin\AbstractAdmin;
11
use Sonata\AdminBundle\Route\RouteCollectionInterface;
12
use Sonata\AdminBundle\Show\ShowMapper;
13
use Sonata\AdminBundle\Form\FormMapper;
14
use Sonata\AdminBundle\Datagrid\ListMapper;
15
use Sonata\AdminBundle\Route\RouteCollection;
16
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
17
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
18
use Symfony\Component\Form\Extension\Core\Type\TextType;
19
20
/**
21
 * Administration manager for the Page Bundle.
22
 */
23
class PageAdmin extends AbstractAdmin
24
{
25
    protected $baseRouteName = 'pnforumbundle_admin_page';
26
27
    /**
28
     * @param RouteCollection $collection
29
     */
30
    protected function configureRoutes(RouteCollectionInterface $collection): void
31
    {
32
        $collection->remove('export');
33
    }
34
35
    /**
36
     * @param FormMapper $form
37
     */
38
    protected function configureFormFields(FormMapper $form): void
39
    {
40
        $form
41
            ->add('id', TextType::class, ['label' => 'label.id', 'attr' => ['readonly' => true]])
42
            ->add('name', TextType::class, ['label' => 'label.name'])
43
            ->add(
44
                'status',
45
                ChoiceType::class,
46
                [
47
                    'label' => 'label.status',
48
                    'choices' => PageStatus::getStatusChoices(),
49
                ]
50
            )
51
            ->add('enabled', CheckboxType::class, [
52
                'label' => 'label.enabled',
53
                'required' => false,
54
            ])
55
            ->add('translations', TranslationsType::class, [
56
                'label' => false,
57
                'required' => true,
58
                'fields' => [
59
                    'title' => [
60
                        'field_type' => TextType::class,
61
                        'label' => 'label.title',
62
                    ],
63
                    'text' => [
64
                        'field_type' => RichTextEditorType::class,
65
                        'label' => 'label.text',
66
                    ]
67
                ]
68
            ]);
69
    }
70
71
    /**
72
     * @param ListMapper $list
73
     */
74
    protected function configureListFields(ListMapper $list): void
75
    {
76
        $list->addIdentifier('id', null, ['label' => 'label.id'])
77
            ->add('name', null, ['label' => 'label.name'])
78
            ->add(
79
                'status',
80
                'choice',
81
                [
82
                    'label' => 'label.status',
83
                    'choices' => PageStatus::getStatusChoices(),
84
                ]
85
            )
86
            ->add('slug', null, ['label' => 'label.slug'])
87
            ->add('enabled', null, ['label' => 'label.enabled'])
88
            ->add('createdAt', null, ['label' => 'label.createdAt'])
89
            ->add('updatedAt', null, ['label' => 'label.updatedAt'])
90
            ->add('_action', 'actions', [
91
                'actions' => [
92
                    'show' => [],
93
                    'edit' => [],
94
                ]
95
            ]);
96
    }
97
98
    /**
99
     * @param ShowMapper $show
100
     */
101
    protected function configureShowFields(ShowMapper $show): void
102
    {
103
        $show
104
            ->add('id', null, ['label' => 'label.id'])
105
            ->add('name', null, ['label' => 'label.name'])
106
            ->add('status', null, ['label' => 'label.status'])
107
            ->add('enabled', null, ['label' => 'label.enabled'])
108
            ->add('createdAt', null, ['label' => 'label.createdAt'])
109
            ->add('updatedAt', null, ['label' => 'label.updatedAt'])
110
            ->add('getText', null, ['label' => 'label.text', 'safe' => true]);
111
    }
112
}
113