1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Silverback\ApiComponentBundle\Entity\Content\Page\Dynamic; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Silverback\ApiComponentBundle\Entity\Component\FileInterface; |
7
|
|
|
use Silverback\ApiComponentBundle\Entity\Component\FileTrait; |
8
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
9
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
10
|
|
|
use Symfony\Component\Validator\Mapping\ClassMetadata; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* |
14
|
|
|
* @author Daniel West <[email protected]> |
15
|
|
|
* @ORM\Entity() |
16
|
|
|
* @ORM\AttributeOverrides({ |
17
|
|
|
* @ORM\AttributeOverride( |
18
|
|
|
* name="filePath", |
19
|
|
|
* column=@ORM\Column( |
20
|
|
|
* nullable=true |
21
|
|
|
* ) |
22
|
|
|
* ) |
23
|
|
|
* }) |
24
|
|
|
*/ |
25
|
|
|
class ArticlePage extends AbstractDynamicPage implements FileInterface |
26
|
|
|
{ |
27
|
|
|
use FileTrait; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @ORM\Column(type="string") |
31
|
|
|
* @Groups({"content", "component", "route"}) |
32
|
|
|
* @var null|string |
33
|
|
|
*/ |
34
|
|
|
private $subtitle; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @ORM\Column(type="text") |
38
|
|
|
* @Groups({"content", "component", "route"}) |
39
|
|
|
* @var string |
40
|
|
|
*/ |
41
|
|
|
private $content; |
42
|
|
|
|
43
|
|
|
public static function loadValidatorMetadata(ClassMetadata $metadata): void |
44
|
|
|
{ |
45
|
|
|
// $metadata->addPropertyConstraint( |
46
|
|
|
// 'filePath', |
47
|
|
|
// new Assert\Image() |
48
|
|
|
// ); |
49
|
|
|
|
50
|
|
|
$metadata->addPropertyConstraint( |
51
|
|
|
'title', |
52
|
|
|
new Assert\NotNull() |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
$metadata->addPropertyConstraint( |
56
|
|
|
'content', |
57
|
|
|
new Assert\NotNull() |
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param null|string $subtitle |
63
|
|
|
*/ |
64
|
|
|
public function setSubtitle(?string $subtitle): void |
65
|
|
|
{ |
66
|
|
|
$this->subtitle = $subtitle; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param string $content |
71
|
|
|
*/ |
72
|
|
|
public function setContent(string $content): void |
73
|
|
|
{ |
74
|
|
|
$this->content = $content; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return null|string |
79
|
|
|
*/ |
80
|
|
|
public function getSubtitle(): ?string |
81
|
|
|
{ |
82
|
|
|
return $this->subtitle; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return string |
87
|
|
|
*/ |
88
|
|
|
public function getContent(): string |
89
|
|
|
{ |
90
|
|
|
return $this->content; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|