1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Silverback\ApiComponentBundle\Entity\Content\Component\Form; |
4
|
|
|
|
5
|
|
|
use ApiPlatform\Core\Annotation\ApiProperty; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use Silverback\ApiComponentBundle\Entity\Content\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\Content\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
|
5 |
|
public static function loadValidatorMetadata(ClassMetadata $metadata): void |
49
|
|
|
{ |
50
|
5 |
|
$metadata->addPropertyConstraints( |
51
|
5 |
|
'formType', |
52
|
|
|
[ |
53
|
5 |
|
new ACBAssert\FormTypeClass(), |
54
|
5 |
|
new Assert\NotBlank() |
55
|
|
|
] |
56
|
|
|
); |
57
|
5 |
|
$metadata->addPropertyConstraint( |
58
|
5 |
|
'successHandler', |
59
|
5 |
|
new ACBAssert\FormHandlerClass() |
60
|
|
|
); |
61
|
5 |
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
6 |
|
public function getFormType(): string |
67
|
|
|
{ |
68
|
6 |
|
return $this->formType; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param string $formType |
73
|
|
|
*/ |
74
|
2 |
|
public function setFormType(string $formType): void |
75
|
|
|
{ |
76
|
2 |
|
$this->formType = $formType; |
77
|
2 |
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return null|string |
81
|
|
|
*/ |
82
|
2 |
|
public function getSuccessHandler(): ?string |
83
|
|
|
{ |
84
|
2 |
|
return $this->successHandler; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param null|string $successHandler |
89
|
|
|
*/ |
90
|
2 |
|
public function setSuccessHandler(?string $successHandler): void |
91
|
|
|
{ |
92
|
2 |
|
$this->successHandler = $successHandler; |
93
|
2 |
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return null|FormView |
97
|
|
|
*/ |
98
|
5 |
|
public function getForm(): ?FormView |
99
|
|
|
{ |
100
|
5 |
|
return $this->form; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param null|FormView $form |
105
|
|
|
*/ |
106
|
5 |
|
public function setForm(?FormView $form): void |
107
|
|
|
{ |
108
|
5 |
|
$this->form = $form; |
109
|
5 |
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return \DateTime|null |
113
|
|
|
*/ |
114
|
1 |
|
public function getLastModified(): ?\DateTime |
115
|
|
|
{ |
116
|
1 |
|
return $this->lastModified; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param \DateTime|null $lastModified |
121
|
|
|
*/ |
122
|
1 |
|
public function setLastModified(?\DateTime $lastModified): void |
123
|
|
|
{ |
124
|
1 |
|
$this->lastModified = $lastModified; |
125
|
1 |
|
} |
126
|
|
|
} |
127
|
|
|
|