EventType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 50
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B buildForm() 0 36 1
1
<?php
2
3
namespace Starkerxp\CampaignBundle\Form\Type;
4
5
use Doctrine\Common\Persistence\ObjectManager;
6
use Starkerxp\CampaignBundle\Entity\Campaign;
7
use Starkerxp\CampaignBundle\Entity\Template;
8
use Starkerxp\CampaignBundle\Repository\CampaignRepository;
9
use Starkerxp\CampaignBundle\Repository\TemplateRepository;
10
use Starkerxp\StructureBundle\Form\Type\AbstractType;
11
use Starkerxp\StructureBundle\Services\EntityToIdObjectTransformer;
12
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
13
use Symfony\Component\Form\FormBuilderInterface;
14
use Symfony\Component\Validator\Constraints;
15
16
class EventType extends AbstractType
17
{
18
    /**
19
     * @var ObjectManager
20
     */
21
    private $manager;
22
23
    public function __construct(ObjectManager $manager)
24
    {
25
        $this->manager = $manager;
26
    }
27
28
    public function buildForm(FormBuilderInterface $builder, array $options)
29
    {
30
        $builder->add(
31
            'campaign',
32
            EntityType::class,
33
            [
34
                'class' => Campaign::class,
35
                'multiple' => false,
36
                'required' => false,
37
                'query_builder' => function (CampaignRepository $repository) {
38
                    return $repository->getQueryListe();
39
                },
40
                'constraints' => [
41
                    new Constraints\NotBlank(),
42
                ],
43
            ]
44
        );
45
        $builder->get('campaign')->addModelTransformer(new EntityToIdObjectTransformer($this->manager, "StarkerxpCampaignBundle:Campaign"));
46
47
        $builder->add(
48
            'template',
49
            EntityType::class,
50
            [
51
                'class' => Template::class,
52
                'multiple' => false,
53
                'required' => false,
54
                'query_builder' => function (TemplateRepository $repository) {
55
                    return $repository->getQueryListe();
56
                },
57
                'constraints' => [
58
                    new Constraints\NotBlank(),
59
                ],
60
            ]
61
        );
62
        $builder->get('template')->addModelTransformer(new EntityToIdObjectTransformer($this->manager, "StarkerxpCampaignBundle:Template"));
63
    }
64
65
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
66