1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Silverback\ApiComponentBundle\Entity\Content\Dynamic; |
4
|
|
|
|
5
|
|
|
use ApiPlatform\Core\Annotation\ApiResource; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use Silverback\ApiComponentBundle\Entity\Content\FileInterface; |
8
|
|
|
use Silverback\ApiComponentBundle\Entity\Content\FileTrait; |
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
|
|
|
* |
15
|
|
|
* @author Daniel West <[email protected]> |
16
|
|
|
* @ApiResource() |
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"}) |
34
|
|
|
* @var null|string |
35
|
|
|
*/ |
36
|
|
|
private $subtitle; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @ORM\Column(type="text") |
40
|
|
|
* @Groups({"content", "component"}) |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
private $content; |
44
|
|
|
|
45
|
6 |
|
public static function loadValidatorMetadata(ClassMetadata $metadata): void |
46
|
|
|
{ |
47
|
6 |
|
$metadata->addPropertyConstraint( |
48
|
6 |
|
'filePath', |
49
|
6 |
|
new Assert\Image() |
50
|
|
|
); |
51
|
|
|
|
52
|
6 |
|
$metadata->addPropertyConstraint( |
53
|
6 |
|
'title', |
54
|
6 |
|
new Assert\NotNull() |
55
|
|
|
); |
56
|
|
|
|
57
|
6 |
|
$metadata->addPropertyConstraint( |
58
|
6 |
|
'content', |
59
|
6 |
|
new Assert\NotNull() |
60
|
|
|
); |
61
|
6 |
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param null|string $subtitle |
65
|
|
|
*/ |
66
|
2 |
|
public function setSubtitle(?string $subtitle): void |
67
|
|
|
{ |
68
|
2 |
|
$this->subtitle = $subtitle; |
69
|
2 |
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param string $content |
73
|
|
|
*/ |
74
|
2 |
|
public function setContent(string $content): void |
75
|
|
|
{ |
76
|
2 |
|
$this->content = $content; |
77
|
2 |
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return null|string |
81
|
|
|
*/ |
82
|
1 |
|
public function getSubtitle(): ?string |
83
|
|
|
{ |
84
|
1 |
|
return $this->subtitle; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
1 |
|
public function getContent(): string |
91
|
|
|
{ |
92
|
1 |
|
return $this->content; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|