|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file was created by developers working at BitBag |
|
5
|
|
|
* Do you need more information about us and what we do? Visit our https://bitbag.io website! |
|
6
|
|
|
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
declare(strict_types=1); |
|
10
|
|
|
|
|
11
|
|
|
namespace BitBag\SyliusCmsPlugin\Entity; |
|
12
|
|
|
|
|
13
|
|
|
use Sylius\Component\Resource\Model\TimestampableTrait; |
|
14
|
|
|
use Sylius\Component\Resource\Model\ToggleableTrait; |
|
15
|
|
|
use Sylius\Component\Resource\Model\TranslatableTrait; |
|
16
|
|
|
use Sylius\Component\Resource\Model\TranslationInterface; |
|
17
|
|
|
|
|
18
|
|
|
class Page implements PageInterface |
|
19
|
|
|
{ |
|
20
|
|
|
use ToggleableTrait; |
|
21
|
|
|
|
|
22
|
|
|
use ProductsAwareTrait; |
|
23
|
|
|
|
|
24
|
|
|
use SectionableTrait; |
|
25
|
|
|
|
|
26
|
|
|
use TimestampableTrait; |
|
27
|
|
|
|
|
28
|
|
|
use ChannelsAwareTrait; |
|
29
|
|
|
|
|
30
|
|
|
use TranslatableTrait { |
|
31
|
|
|
__construct as protected initializeTranslationsCollection; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** @var int */ |
|
35
|
|
|
protected $id; |
|
36
|
|
|
|
|
37
|
|
|
/** @var string|null */ |
|
38
|
|
|
protected $code; |
|
39
|
|
|
|
|
40
|
|
|
/** @var \DateTimeImmutable|null */ |
|
41
|
|
|
protected $publishAt; |
|
42
|
|
|
|
|
43
|
|
|
public function __construct() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->initializeProductsCollection(); |
|
46
|
|
|
$this->initializeSectionsCollection(); |
|
47
|
|
|
$this->initializeTranslationsCollection(); |
|
48
|
|
|
$this->initializeChannelsCollection(); |
|
49
|
|
|
$this->initializeChannelsCollection(); |
|
50
|
|
|
|
|
51
|
|
|
$this->createdAt = new \DateTime(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function getId(): ?int |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->id; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function setId(int $id): void |
|
60
|
|
|
{ |
|
61
|
|
|
$this->id = $id; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function getCode(): ?string |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->code; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function setCode(?string $code): void |
|
70
|
|
|
{ |
|
71
|
|
|
$this->code = $code; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function getSlug(): ?string |
|
75
|
|
|
{ |
|
76
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
77
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
78
|
|
|
|
|
79
|
|
|
return $pageTranslationInterface->getSlug(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function setSlug(?string $slug): void |
|
83
|
|
|
{ |
|
84
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
85
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
86
|
|
|
$pageTranslationInterface->setSlug($slug); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function getMetaKeywords(): ?string |
|
90
|
|
|
{ |
|
91
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
92
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
93
|
|
|
|
|
94
|
|
|
return $pageTranslationInterface->getMetaKeywords(); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function setMetaKeywords(?string $metaKeywords): void |
|
98
|
|
|
{ |
|
99
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
100
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
101
|
|
|
$pageTranslationInterface->setMetaKeywords($metaKeywords); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function getMetaDescription(): ?string |
|
105
|
|
|
{ |
|
106
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
107
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
108
|
|
|
|
|
109
|
|
|
return $pageTranslationInterface->getMetaDescription(); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function setMetaDescription(?string $metaDescription): void |
|
113
|
|
|
{ |
|
114
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
115
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
116
|
|
|
$pageTranslationInterface->setMetaDescription($metaDescription); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function getContent(): ?string |
|
120
|
|
|
{ |
|
121
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
122
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
123
|
|
|
|
|
124
|
|
|
return $pageTranslationInterface->getContent(); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function setContent(?string $content): void |
|
128
|
|
|
{ |
|
129
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
130
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
131
|
|
|
$pageTranslationInterface->setContent($content); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function getName(): ?string |
|
135
|
|
|
{ |
|
136
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
137
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
138
|
|
|
|
|
139
|
|
|
return $pageTranslationInterface->getName(); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
public function setName(?string $name): void |
|
143
|
|
|
{ |
|
144
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
145
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
146
|
|
|
$pageTranslationInterface->setName($name); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
public function getNameWhenLinked(): ?string |
|
150
|
|
|
{ |
|
151
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
152
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
153
|
|
|
|
|
154
|
|
|
return $pageTranslationInterface->getNameWhenLinked(); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
public function setNameWhenLinked(?string $nameWhenLinked): void |
|
158
|
|
|
{ |
|
159
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
160
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
161
|
|
|
$pageTranslationInterface->setNameWhenLinked($nameWhenLinked); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
public function getDescriptionWhenLinked(): ?string |
|
165
|
|
|
{ |
|
166
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
167
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
168
|
|
|
|
|
169
|
|
|
return $pageTranslationInterface->getDescriptionWhenLinked(); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
public function setDescriptionWhenLinked(?string $descriptionWhenLinked): void |
|
173
|
|
|
{ |
|
174
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
175
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
176
|
|
|
$pageTranslationInterface->setDescriptionWhenLinked($descriptionWhenLinked); |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
public function getBreadcrumb(): ?string |
|
180
|
|
|
{ |
|
181
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
182
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
183
|
|
|
|
|
184
|
|
|
return $pageTranslationInterface->getBreadcrumb(); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
public function setBreadcrumb(?string $breadcrumb): void |
|
188
|
|
|
{ |
|
189
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
190
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
191
|
|
|
$pageTranslationInterface->setBreadcrumb($breadcrumb); |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
public function getImage(): ?MediaInterface |
|
195
|
|
|
{ |
|
196
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
197
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
198
|
|
|
|
|
199
|
|
|
return $pageTranslationInterface->getImage(); |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
public function setImage(?MediaInterface $image): void |
|
203
|
|
|
{ |
|
204
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
205
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
206
|
|
|
$pageTranslationInterface->setImage($image); |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
public function getTitle(): ?string |
|
210
|
|
|
{ |
|
211
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
212
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
213
|
|
|
|
|
214
|
|
|
return $pageTranslationInterface->getTitle(); |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
public function setTitle(?string $title): void |
|
218
|
|
|
{ |
|
219
|
|
|
/** @var PageTranslationInterface $pageTranslationInterface */ |
|
220
|
|
|
$pageTranslationInterface = $this->getPageTranslation(); |
|
221
|
|
|
$pageTranslationInterface->setTitle($title); |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
/** |
|
225
|
|
|
* @return PageTranslationInterface|TranslationInterface |
|
226
|
|
|
*/ |
|
227
|
|
|
protected function getPageTranslation(): TranslationInterface |
|
228
|
|
|
{ |
|
229
|
|
|
return $this->getTranslation(); |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
protected function createTranslation(): PageTranslationInterface |
|
233
|
|
|
{ |
|
234
|
|
|
return new PageTranslation(); |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
public function getPublishAt(): ?\DateTimeImmutable |
|
238
|
|
|
{ |
|
239
|
|
|
return $this->publishAt; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
public function setPublishAt(?\DateTimeImmutable $publishAt): void |
|
243
|
|
|
{ |
|
244
|
|
|
$this->publishAt = $publishAt; |
|
245
|
|
|
} |
|
246
|
|
|
} |
|
247
|
|
|
|