Completed
Push — master ( 9cee5d...f0143d )
by Piotr
13s
created

SubscriberForm::initForm()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 38
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 38
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 24
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 array('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'),
0 ignored issues
show
Bug introduced by
It seems like \FSi\Bundle\AdminBundle\...ype\\FormType', 'form') targeting FSi\Bundle\AdminBundle\F...peSolver::getFormType() can also be of type object<Symfony\Component\Form\FormTypeInterface>; however, Symfony\Component\Form\F...e::createNamedBuilder() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
48
            $data,
49
            array(
50
                'data_class' => $this->getClassName()
51
            )
52
        );
53
54
        $builder->add(
55
            'email',
56
            TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\EmailType', 'email'),
0 ignored issues
show
Bug introduced by
It seems like \FSi\Bundle\AdminBundle\...e\\EmailType', 'email') targeting FSi\Bundle\AdminBundle\F...peSolver::getFormType() can also be of type object<Symfony\Component\Form\FormTypeInterface>; however, Symfony\Component\Form\FormBuilderInterface::add() does only seem to accept string|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
57
            array(
58
                'label' => 'admin.subscriber.list.email',
59
            )
60
        );
61
62
        $builder->add(
63
            'created_at',
64
            TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\DateType', 'date'),
0 ignored issues
show
Bug introduced by
It seems like \FSi\Bundle\AdminBundle\...ype\\DateType', 'date') targeting FSi\Bundle\AdminBundle\F...peSolver::getFormType() can also be of type object<Symfony\Component\Form\FormTypeInterface>; however, Symfony\Component\Form\FormBuilderInterface::add() does only seem to accept string|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
65
            array(
66
                'label' => 'admin.subscriber.list.created_at',
67
                'widget' => 'single_text'
68
            )
69
        );
70
71
        $builder->add(
72
            'active',
73
            TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\CheckboxType', 'checkbox'),
0 ignored issues
show
Bug introduced by
It seems like \FSi\Bundle\AdminBundle\...ckboxType', 'checkbox') targeting FSi\Bundle\AdminBundle\F...peSolver::getFormType() can also be of type object<Symfony\Component\Form\FormTypeInterface>; however, Symfony\Component\Form\FormBuilderInterface::add() does only seem to accept string|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
74
            array(
75
                'label' => 'admin.subscriber.list.active',
76
            )
77
        );
78
79
        return $builder->getForm();
80
    }
81
}
82