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