Completed
Pull Request — 3.1 (#348)
by Piotr
07:35
created

DTOFormElement::getClassName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
declare(strict_types=1);
11
12
namespace FSi\FixturesBundle\Admin;
13
14
use FSi\Bundle\AdminBundle\Doctrine\Admin\FormElement;
15
use FSi\FixturesBundle\DTO\Model;
16
use Symfony\Component\Form\Extension\Core\Type\EmailType;
17
use Symfony\Component\Form\Extension\Core\Type\FormType;
18
use Symfony\Component\Form\FormFactoryInterface;
19
use Symfony\Component\Form\FormInterface;
20
21
class DTOFormElement extends FormElement
22
{
23
    public function getClassName(): string
24
    {
25
        return Model::class;
26
    }
27
28
    public function getId(): string
29
    {
30
        return 'dto_form';
31
    }
32
33
    public function save($data): void
34
    {
35
    }
36
37
    protected function initForm(FormFactoryInterface $factory, $data = null): FormInterface
38
    {
39
        $builder = $factory->createNamedBuilder(
40
            'dto_form',
41
            FormType::class,
42
            $data,
43
            ['data_class' => $this->getClassName()]
44
        );
45
46
        $builder->add(
47
            'email',
48
            EmailType::class,
49
            ['label' => 'admin.email']
50
        );
51
52
        return $builder->getForm();
53
    }
54
}
55