ImageAjaxType::getParent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * Copyright 2014 Jonathan Bouzekri. All rights reserved.
5
 *
6
 * @copyright Copyright 2014 Jonathan Bouzekri <[email protected]>
7
 * @license https://github.com/jbouzekri/FileUploaderBundle/blob/master/LICENSE
8
 * @link https://github.com/jbouzekri/FileUploaderBundle
9
 */
10
11
namespace Jb\Bundle\FileUploaderBundle\Form\Type;
12
13
use Symfony\Component\Form\AbstractType;
14
use Symfony\Component\OptionsResolver\OptionsResolver;
15
use Symfony\Component\Form\FormView;
16
use Symfony\Component\Form\FormInterface;
17
18
/**
19
 * Class ImageAjaxType
20
 * @package Jb\Bundle\FileUploaderBundle\Form\Type
21
 */
22
class ImageAjaxType extends AbstractType
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27
    public function configureOptions(OptionsResolver $resolver)
28
    {
29
        $resolver->setDefined(array(
30
            'default_image',
31
            'img_width',
32
            'img_height'
33
        ));
34
35
        $resolver->setDefaults(
36
            array(
37
                'default_image' => 'bundles/jbfileuploader/img/default.png',
38
                'loading_file' => 'bundles/jbfileuploader/img/ajax-loader.gif',
39
            )
40
        );
41
    }
42
43
    /**
44
     * {@inheritDoc}
45
     */
46
    public function buildView(FormView $view, FormInterface $form, array $options)
47
    {
48
        $view->vars['download_link'] = false;
49
        $view->vars['default_image'] = $options['default_image'];
50
51
        if (isset($options['img_width'])) {
52
            $view->vars['img_width'] = $options['img_width'];
53
        }
54
55
        if (isset($options['img_height'])) {
56
            $view->vars['img_height'] = $options['img_height'];
57
        }
58
    }
59
60
    /**
61
     * {@inheritDoc}
62
     */
63
    public function getParent()
64
    {
65
        return FileAjaxType::class;
66
    }
67
}
68