VideoType::getBlockPrefix()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace AppBundle\Form;
4
5
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
6
use Symfony\Component\Form\AbstractType;
7
use Symfony\Component\Form\FormBuilderInterface;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
use Vich\UploaderBundle\Form\Type\VichFileType;
10
11
class VideoType extends AbstractType
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function buildForm(FormBuilderInterface $builder, array $options)
17
    {
18
        $builder
19
            ->add('title', null, ['label' => 'form_create.title'])
20
            ->add('description', null, ['label' => 'form_create.description'])
21
            ->add('tags', EntityType::class, array(
22
                'class' => 'AppBundle:Tag',
23
                'choice_label' => 'name',
24
                'multiple' => true,
25
                'label' => 'form_create.categories',
26
            ));
27
28
        if ($options['action_type'] === 'edit') {
29
            $builder->add('videoFile', VichFileType::class, [
30
                'download_link' => false,
31
                'allow_delete' => false,
32
                'required' => false,
33
                'label' => 'form_create.file',
34
            ]);
35
        }
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function configureOptions(OptionsResolver $resolver)
42
    {
43
        $resolver->setDefaults(array(
44
            'data_class' => 'AppBundle\Entity\Video',
45
            'action_type' => 'create',
46
            'translation_domain' => 'video',
47
        ));
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function getBlockPrefix()
54
    {
55
        return 'appbundle_video';
56
    }
57
}
58