Completed
Pull Request — 5.0 (#2162)
by Kevin
14:33
created

MediaBundle/Form/RemoteSlide/RemoteSlideType.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\MediaBundle\Form\RemoteSlide;
4
5
use Kunstmaan\MediaBundle\Form\AbstractRemoteType;
6
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
7
use Symfony\Component\Form\FormBuilderInterface;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
use Symfony\Component\Validator\Constraints\NotBlank;
10
11
/**
12
 * RemoteSlideType
13
 */
14 View Code Duplication
class RemoteSlideType extends AbstractRemoteType
0 ignored issues
show
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...
15
{
16
    /**
17
     * Builds the form.
18
     *
19
     * This method is called for each type in the hierarchy starting form the
20
     * top most type. Type extensions can further modify the form.
21
     *
22
     * @param FormBuilderInterface $builder The form builder
23
     * @param array                $options The options
24
     *
25
     * @see FormTypeExtensionInterface::buildForm()
26
     */
27
    public function buildForm(FormBuilderInterface $builder, array $options)
28
    {
29
        parent::buildForm($builder, $options);
30
        $builder
31
            ->add(
32
                'type',
33
                ChoiceType::class,
34
                array(
35
                    'label'       => 'media.form.remote_slide.type.label',
36
                    'choices'     => array('slideshare' => 'slideshare'),
37
                    'constraints' => array(new NotBlank()),
38
                    'required'    => true
39
                )
40
            );
41
    }
42
43
    /**
44
     * Returns the name of this type.
45
     *
46
     * @return string The name of this type
47
     */
48
    public function getBlockPrefix()
49
    {
50
        return 'kunstmaan_mediabundle_slidetype';
51
    }
52
53
    /**
54
     * Sets the default options for this type.
55
     *
56
     * @param OptionsResolver $resolver The resolver for the options.
57
     */
58
    public function configureOptions(OptionsResolver $resolver)
59
    {
60
        $resolver->setDefaults(
61
            array(
62
                'data_class' => 'Kunstmaan\MediaBundle\Helper\RemoteSlide\RemoteSlideHelper',
63
            )
64
        );
65
    }
66
}
67