Completed
Pull Request — master (#343)
by Leny
09:31
created

StaticTextExtension::configureOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 8
Ratio 100 %
Metric Value
dl 8
loc 8
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Victoire\Bundle\FormBundle\Form\Extension;
4
5
/*
6
 * This file is part of the MopaBootstrapBundle.
7
 *
8
 * (c) Philipp A. Mohrenweiser <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
use Symfony\Component\Form\AbstractTypeExtension;
15
use Symfony\Component\Form\Extension\Core\Type\FormType;
16
use Symfony\Component\Form\FormInterface;
17
use Symfony\Component\Form\FormView;
18
use Symfony\Component\OptionsResolver\OptionsResolver;
19
20
/**
21
 * Extension for creating static text (form-control-static).
22
 *
23
 * @author peshi <[email protected]>
24
 */
25 View Code Duplication
class StaticTextExtension extends AbstractTypeExtension
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function getExtendedType()
31
    {
32
        return FormType::class;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function configureOptions(OptionsResolver $resolver)
39
    {
40
        $resolver->setDefaults(
41
            [
42
                'vic_static_text' => null,
43
            ]
44
        );
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function buildView(FormView $view, FormInterface $form, array $options)
51
    {
52
        $view->vars['vic_static_text'] = $options['vic_static_text'];
53
        if ($options['vic_static_text'] == true) {
54
            $view->vars['disabled'] = true;
55
        }
56
    }
57
}
58