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