Completed
Push — master ( 5a2c46...47cba7 )
by Jarek
11s
created

SubscriberForm::initForm()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 20
nc 1
nop 2
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace FSi\FixturesBundle\Admin;
11
12
use FSi\Bundle\AdminBundle\Doctrine\Admin\FormElement;
13
use FSi\Bundle\AdminBundle\Form\TypeSolver;
14
use Symfony\Component\Form\FormFactoryInterface;
15
16
class SubscriberForm extends FormElement
17
{
18
    public function getClassName()
19
    {
20
        return 'FSi\FixturesBundle\Entity\Subscriber';
21
    }
22
23
    public function getId()
24
    {
25
        return 'subscriber_form';
26
    }
27
28
    public function getName()
29
    {
30
        return 'admin.subscriber.name';
31
    }
32
33
    public function getSuccessRoute()
34
    {
35
        return 'fsi_admin_list';
36
    }
37
38
    public function getSuccessRouteParameters()
39
    {
40
        return ['element' => 'subscriber'];
41
    }
42
43
    protected function initForm(FormFactoryInterface $factory, $data = null)
44
    {
45
        $builder = $factory->createNamedBuilder(
46
            'subscriber',
47
            TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\FormType', 'form'),
48
            $data,
49
            ['data_class' => $this->getClassName()]
50
        );
51
52
        $builder->add(
53
            'email',
54
            TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\EmailType', 'email'),
55
            ['label' => 'admin.subscriber.list.email']
56
        );
57
58
        $builder->add(
59
            'created_at',
60
            TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\DateType', 'date'),
61
            [
62
                'label' => 'admin.subscriber.list.created_at',
63
                'widget' => 'single_text'
64
            ]
65
        );
66
67
        $builder->add(
68
            'active',
69
            TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\CheckboxType', 'checkbox'),
70
            ['label' => 'admin.subscriber.list.active']
71
        );
72
73
        return $builder->getForm();
74
    }
75
}
76