Completed
Push — master ( 5d51b4...87fdd9 )
by Paul
10s
created

PageSettingsType::buildForm()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 30
rs 8.8571
cc 1
eloc 20
nc 1
nop 2
1
<?php
2
3
namespace Victoire\Bundle\PageBundle\Form;
4
5
use A2lix\TranslationFormBundle\Form\Type\TranslationsType;
6
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
7
use Symfony\Component\Form\FormBuilderInterface;
8
use Symfony\Component\HttpFoundation\RequestStack;
9
use Victoire\Bundle\FormBundle\Form\Type\UrlvalidatedType;
10
use Victoire\Bundle\PageBundle\Entity\PageStatus;
11
12
/**
13
 * Edit Page Type.
14
 */
15
class PageSettingsType extends PageType
16
{
17
    /**
18
     * Constructor.
19
     */
20
    public function __construct($availableLocales, RequestStack $requestStack)
21
    {
22
        parent::__construct($availableLocales, $requestStack);
23
    }
24
25
    /**
26
     * define form fields.
27
     *
28
     * @param FormBuilderInterface $builder
29
     * @param array                $options
30
     */
31
    public function buildForm(FormBuilderInterface $builder, array $options)
32
    {
33
        parent::buildForm($builder, $options);
34
35
        $builder->add('translations', TranslationsType::class, [
36
            'fields' => [
37
                'name' => [
38
                    'label' => 'form.view.type.name.label',
39
                ],
40
                'slug' => [
41
                    'label'      => 'form.page.type.slug.label',
42
                    'field_type' => UrlvalidatedType::class,
43
                ],
44
            ],
45
        ])
46
        ->add('status', ChoiceType::class, [
47
            'label'   => 'form.page.type.status.label',
48
            'choices' => [
49
                'form.page.type.status.choice.label.draft'       => PageStatus::DRAFT,
50
                'form.page.type.status.choice.label.published'   => PageStatus::PUBLISHED,
51
                'form.page.type.status.choice.label.unpublished' => PageStatus::UNPUBLISHED,
52
                'form.page.type.status.choice.label.scheduled'   => PageStatus::SCHEDULED,
53
            ],
54
            'choices_as_values' => true,
55
        ])
56
        ->add('publishedAt', null, [
57
            'widget'             => 'single_text',
58
            'vic_datetimepicker' => true,
59
        ]);
60
    }
61
}
62