AdventureType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 52
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B buildForm() 0 36 1
A configureOptions() 0 6 1
1
<?php
2
3
namespace Badger\Bundle\GameBundle\Form;
4
5
use Badger\Bundle\GameBundle\Entity\Adventure;
6
use Badger\Bundle\GameBundle\Entity\Badge;
7
use Badger\Bundle\GameBundle\Entity\Tag;
8
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
9
use Symfony\Component\Form\AbstractType;
10
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
11
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
12
use Symfony\Component\Form\FormBuilderInterface;
13
use Symfony\Component\OptionsResolver\OptionsResolver;
14
15
/**
16
 * @author  Marie Bochu <[email protected]>
17
 * @license http://opensource.org/licenses/MIT The MIT License (MIT)
18
 */
19
class AdventureType extends AbstractType
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function buildForm(FormBuilderInterface $builder, array $options)
25
    {
26
        $builder
27
            ->add('title')
28
            ->add('description', TextareaType::class, [
29
                'attr' => [
30
                    'rows' => 3
31
                ]
32
            ])
33
            ->add('rewardPoint', null, [
34
                'label' => 'game.adventure.form.reward_point'
35
            ])
36
            ->add('isStepLinked')
37
            ->add('badge', EntityType::class, [
38
                'class'        => Badge::class,
39
                'choice_label' => 'title',
40
                'empty_data'   => '',
41
                'required'     => false,
42
                'label'        => 'game.adventure.form.badge'
43
            ])
44
            ->add('steps', CollectionType::class, [
45
                'entry_type'   => AdventureStepType::class,
46
                'allow_add'    => true,
47
                'allow_delete' => true,
48
                'by_reference' => false,
49
                'label'        => false
50
            ])
51
            ->add('tags', EntityType::class, [
52
                'label'        => 'Tagged in',
53
                'multiple'     => true,
54
                'choice_label' => 'name',
55
                'required'     => false,
56
                'class'        => Tag::class
57
            ])
58
        ;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function configureOptions(OptionsResolver $resolver)
65
    {
66
        $resolver->setDefaults([
67
            'data_class' => Adventure::class
68
        ]);
69
    }
70
}
71