Test Failed
Push — develop ( b13210...c32797 )
by Daniel
04:26
created

Form::setLastModified()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity\Component\Form;
4
5
use ApiPlatform\Core\Annotation\ApiProperty;
6
use Doctrine\ORM\Mapping as ORM;
7
use Silverback\ApiComponentBundle\Entity\Component\AbstractComponent;
8
use Silverback\ApiComponentBundle\Validator\Constraints as ACBAssert;
9
use Symfony\Component\Serializer\Annotation\Groups;
10
use Symfony\Component\Validator\Constraints as Assert;
11
use Symfony\Component\Validator\Mapping\ClassMetadata;
12
13
/**
14
 * Class Form
15
 * @package Silverback\ApiComponentBundle\Entity\Component\Form
16
 * @author Daniel West <[email protected]>
17
 * @ORM\Entity()
18
 */
19
class Form extends AbstractComponent
20
{
21
    /**
22
     * @ORM\Column()
23
     * @Groups({"component_write"})
24
     * @var string
25
     */
26
    private $formType;
27
28
    /**
29
     * @ORM\Column()
30
     * @Groups({"component_write"})
31
     * @var null|string
32
     */
33
    private $successHandler;
34
35
    /**
36
     * @ApiProperty(writable=false)
37
     * @var null|\DateTime
38
     */
39
    private $lastModified;
40
41
    /**
42
     * @ApiProperty(writable=false)
43
     * @Groups({"component", "content"})
44
     * @var null|FormView
45
     */
46
    private $form;
47
48
    public static function loadValidatorMetadata(ClassMetadata $metadata): void
49
    {
50
        $metadata->addPropertyConstraints(
51
            'formType',
52
            [
53
                new ACBAssert\FormTypeClass(),
54
                new Assert\NotBlank()
55
            ]
56
        );
57
        $metadata->addPropertyConstraint(
58
            'successHandler',
59
            new ACBAssert\FormHandlerClass()
60
        );
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function getFormType(): string
67
    {
68
        return $this->formType;
69
    }
70
71
    /**
72
     * @param string $formType
73
     */
74
    public function setFormType(string $formType): void
75
    {
76
        $this->formType = $formType;
77
    }
78
79
    /**
80
     * @return null|string
81
     */
82
    public function getSuccessHandler(): ?string
83
    {
84
        return $this->successHandler;
85
    }
86
87
    /**
88
     * @param null|string $successHandler
89
     */
90
    public function setSuccessHandler(?string $successHandler): void
91
    {
92
        $this->successHandler = $successHandler;
93
    }
94
95
    /**
96
     * @return null|FormView
97
     */
98
    public function getForm(): ?FormView
99
    {
100
        return $this->form;
101
    }
102
103
    /**
104
     * @param null|FormView $form
105
     */
106
    public function setForm(?FormView $form): void
107
    {
108
        $this->form = $form;
109
    }
110
111
    /**
112
     * @return \DateTime|null
113
     */
114
    public function getLastModified(): ?\DateTime
115
    {
116
        return $this->lastModified;
117
    }
118
119
    /**
120
     * @param \DateTime|null $lastModified
121
     */
122
    public function setLastModified(?\DateTime $lastModified): void
123
    {
124
        $this->lastModified = $lastModified;
125
    }
126
}
127