ImageType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 49
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A buildView() 0 9 1
A configureOptions() 0 14 1
A getBlockPrefix() 0 4 1
A getParent() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the `liip/LiipImagineBundle` project.
5
 *
6
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Liip\ImagineBundle\Form\Type;
13
14
use Symfony\Component\Form\AbstractType;
15
use Symfony\Component\Form\Extension\Core\Type\FileType;
16
use Symfony\Component\Form\FormInterface;
17
use Symfony\Component\Form\FormView;
18
use Symfony\Component\OptionsResolver\OptionsResolver;
19
20
/**
21
 * ImageType.
22
 *
23
 * @author Emmanuel Vella <[email protected]>
24
 */
25
class ImageType extends AbstractType
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function buildView(FormView $view, FormInterface $form, array $options)
31
    {
32
        $view->vars['image_path'] = $options['image_path'];
33
        $view->vars['image_filter'] = $options['image_filter'];
34
        $view->vars['image_attr'] = $options['image_attr'];
35
        $view->vars['link_url'] = $options['link_url'];
36
        $view->vars['link_filter'] = $options['link_filter'];
37
        $view->vars['link_attr'] = $options['link_attr'];
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function configureOptions(OptionsResolver $resolver)
44
    {
45
        $resolver->setRequired([
46
            'image_path',
47
            'image_filter',
48
        ]);
49
50
        $resolver->setDefaults([
51
            'image_attr' => [],
52
            'link_url' => null,
53
            'link_filter' => null,
54
            'link_attr' => [],
55
        ]);
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function getBlockPrefix()
62
    {
63
        return 'liip_imagine_image';
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function getParent()
70
    {
71
        return FileType::class;
72
    }
73
}
74