ImageExtension   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 51
ccs 0
cts 36
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configureListFields() 0 10 1
A configureFormFields() 0 13 1
A configureShowFields() 0 14 1
1
<?php
2
3
namespace Smart\ContentBundle\Admin\Extension;
4
5
use Sonata\AdminBundle\Admin\AbstractAdminExtension;
6
use Sonata\AdminBundle\Datagrid\ListMapper;
7
use Sonata\AdminBundle\Form\FormMapper;
8
use Sonata\AdminBundle\Show\ShowMapper;
9
use Vich\UploaderBundle\Form\Type\VichImageType;
10
11
/**
12
 * Nicolas Bastien <[email protected]>
13
 */
14
class ImageExtension extends AbstractAdminExtension
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function configureListFields(ListMapper $list)
20
    {
21
22
        $list
23
            ->add('imageFile', null, [
24
                'template' => '@SmartContent/admin/list_field_image.html.twig',
25
                'label' => 'form.label_image'
26
            ])
27
        ;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function configureFormFields(FormMapper $form)
34
    {
35
        $form
36
            ->tab('tab.label_content')
37
                ->with('fieldset.label_parameters', ['class' => 'col-md-4'])
38
                    ->add('imageFile', VichImageType::class, [
39
                        'required' => false,
40
                        'label' => 'form.label_image'
41
                    ])
42
                ->end()
43
            ->end()
44
        ;
45
    }
46
47
    /**
48
     * {@inheritDoc}
49
     */
50
    public function configureShowFields(ShowMapper $show)
51
    {
52
        $show
53
            ->tab('tab.label_content')
54
                ->with('fieldset.label_parameters', ['class' => 'col-md-4'])
55
                    ->add('imageFile', null, [
56
                        'template'  => '@SmartContent/admin/show_image.html.twig',
57
                        'fieldName' => 'imageFile',
58
                        'label' => 'form.label_image'
59
                    ])
60
                ->end()
61
            ->end()
62
        ;
63
    }
64
}
65