1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Silverback\ApiComponentBundle\Entity\Content; |
4
|
|
|
|
5
|
|
|
use ApiPlatform\Core\Annotation\ApiProperty; |
6
|
|
|
use ApiPlatform\Core\Annotation\ApiResource; |
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
use Silverback\ApiComponentBundle\Entity\Layout\Layout; |
9
|
|
|
use Silverback\ApiComponentBundle\Entity\Route\RouteAwareInterface; |
10
|
|
|
use Silverback\ApiComponentBundle\Entity\Route\RouteAwareTrait; |
11
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class Page |
15
|
|
|
* @package Silverback\ApiComponentBundle\Entity\Content |
16
|
|
|
* @author Daniel West <[email protected]> |
17
|
|
|
* @ApiResource() |
18
|
|
|
* @ORM\Entity() |
19
|
|
|
*/ |
20
|
|
|
class Page extends AbstractContent implements RouteAwareInterface |
21
|
|
|
{ |
22
|
|
|
use RouteAwareTrait; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @ORM\Column() |
26
|
|
|
* @Groups({"content"}) |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private $title; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @ORM\Column() |
33
|
|
|
* @Groups({"content"}) |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
private $metaDescription; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @ORM\ManyToOne(targetEntity="Page") |
40
|
|
|
* @ORM\JoinColumn(nullable=true) |
41
|
|
|
* @var null|Page |
42
|
|
|
*/ |
43
|
|
|
private $parent; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @ORM\ManyToOne(targetEntity="Silverback\ApiComponentBundle\Entity\Layout\Layout") |
47
|
|
|
* @ORM\JoinColumn(onDelete="SET NULL") |
48
|
|
|
* @ApiProperty() |
49
|
|
|
* @Groups({"content"}) |
50
|
|
|
* @var Layout|null |
51
|
|
|
*/ |
52
|
|
|
private $layout; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return string |
56
|
|
|
*/ |
57
|
1 |
|
public function getTitle(): string |
58
|
|
|
{ |
59
|
1 |
|
return $this->title; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param string $title |
64
|
|
|
*/ |
65
|
2 |
|
public function setTitle(string $title): void |
66
|
|
|
{ |
67
|
2 |
|
$this->title = $title; |
68
|
2 |
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
1 |
|
public function getMetaDescription(): string |
74
|
|
|
{ |
75
|
1 |
|
return $this->metaDescription; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param string $metaDescription |
80
|
|
|
*/ |
81
|
2 |
|
public function setMetaDescription(string $metaDescription): void |
82
|
|
|
{ |
83
|
2 |
|
$this->metaDescription = $metaDescription; |
84
|
2 |
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return null|Page |
88
|
|
|
*/ |
89
|
1 |
|
public function getParent(): ?Page |
90
|
|
|
{ |
91
|
1 |
|
return $this->parent; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param null|Page $parent |
96
|
|
|
*/ |
97
|
2 |
|
public function setParent(?Page $parent): void |
98
|
|
|
{ |
99
|
2 |
|
$this->parent = $parent; |
100
|
2 |
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return Layout|null |
104
|
|
|
*/ |
105
|
1 |
|
public function getLayout(): ?Layout |
106
|
|
|
{ |
107
|
1 |
|
return $this->layout; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @param Layout|null $layout |
112
|
|
|
*/ |
113
|
2 |
|
public function setLayout(?Layout $layout): void |
114
|
|
|
{ |
115
|
2 |
|
$this->layout = $layout; |
116
|
2 |
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @inheritdoc |
120
|
|
|
*/ |
121
|
|
|
public function getDefaultRoute(): string |
122
|
|
|
{ |
123
|
|
|
return $this->getTitle(); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|