Issues (2)

src/Admin/MessageAdmin.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProjetNormandie\MessageBundle\Admin;
6
7
use FOS\CKEditorBundle\Form\Type\CKEditorType;
0 ignored issues
show
The type FOS\CKEditorBundle\Form\Type\CKEditorType 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...
8
use Sonata\AdminBundle\Admin\AbstractAdmin;
9
use Sonata\AdminBundle\Form\Type\ModelAutocompleteType;
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\RouteCollectionInterface;
15
use Sonata\DoctrineORMAdminBundle\Filter\ModelFilter;
16
use Symfony\Component\Form\Extension\Core\Type\TextType;
17
use Sonata\AdminBundle\Form\Type\ModelListType;
18
19
class MessageAdmin extends AbstractAdmin
20
{
21
    protected $baseRouteName = 'pnmessagebundle_admin_message';
22
23
    /**
24
     * @param RouteCollectionInterface $collection
25
     */
26
    protected function configureRoutes(RouteCollectionInterface $collection): void
27
    {
28
        $collection->remove('export')
29
            ->remove('create');
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('sender', ModelListType::class, [
39
                'data_class' => null,
40
                'btn_add' => false,
41
                'btn_list' => false,
42
                'btn_delete' => false,
43
                'btn_catalogue' => false,
44
                'label' => 'Sender',
45
                'required' => false
46
            ])
47
            ->add('recipient', ModelListType::class, [
48
                'data_class' => null,
49
                'btn_add' => false,
50
                'btn_list' => false,
51
                'btn_delete' => false,
52
                'btn_catalogue' => false,
53
                'label' => 'label.recipient',
54
            ])
55
            ->add('object', TextType::class, ['label' => 'label.object'])
56
            ->add('message', CKEditorType::class, [
57
                'label' => 'label.message',
58
                'required' => true,
59
                'config' => array(
60
                    'height' => '200',
61
                    'toolbar' => 'standard'
62
                ),
63
            ]);
64
    }
65
66
    /**
67
     * @param DatagridMapper $filter
68
     */
69
    protected function configureDatagridFilters(DatagridMapper $filter): void
70
    {
71
        $filter
72
            ->add('sender', ModelFilter::class, [
73
                'label' => 'label.sender',
74
                'field_type' => ModelAutocompleteType::class,
75
                'field_options' => ['property'=>'username'],
76
            ])
77
            ->add('recipient', ModelFilter::class, [
78
                'label' => 'label.recipient',
79
                'field_type' => ModelAutocompleteType::class,
80
                'field_options' => ['property'=>'username'],
81
            ])
82
            ->add('isDeletedSender', null, ['label' => 'label.isDeletedSender'])
83
            ->add('isDeletedRecipient', null, ['label' => 'label.isDeletedRecipient'])
84
            ->add('type', null, ['label' => 'label.type']);
85
    }
86
87
    /**
88
     * @param ListMapper $list
89
     */
90
    protected function configureListFields(ListMapper $list): void
91
    {
92
        $list->addIdentifier('id', null, ['label' => 'label.id'])
93
            ->add('type', null, ['label' => 'label.type'])
94
            ->add('object', null, ['label' => 'label.object'])
95
            ->add('sender', null, ['label' => 'label.sender'])
96
            ->add('isDeletedSender', null, ['label' => 'label.isDeletedSender'])
97
            ->add('recipient', null, ['label' => 'label.recipient'])
98
            ->add('isDeletedRecipient', null, ['label' => 'label.isDeletedRecipient'])
99
            ->add('createdAt', null, ['label' => 'label.createdAt'])
100
            ->add('_action', 'actions', ['actions' => ['show' => [], 'edit' => []]]);
101
    }
102
103
    /**
104
     * @param ShowMapper $show
105
     */
106
    protected function configureShowFields(ShowMapper $show): void
107
    {
108
        $show->add('id', null, ['label' => 'label.id'])
109
            ->add('type', null, ['label' => 'label.type'])
110
            ->add('object', null, ['label' => 'label.object'])
111
            ->add('sender', null, ['label' => 'label.sender'])
112
            ->add('isDeletedSender', null, ['label' => 'label.isDeletedSender'])
113
            ->add('recipient', null, ['label' => 'label.recipient'])
114
            ->add('isDeletedRecipient', null, ['label' => 'label.isDeletedRecipient'])
115
            ->add('createdAt', null, ['label' => 'label.createdAt'])
116
            ->add('message', null, ['label' => 'label.message', 'safe' => true]);
117
    }
118
}
119