1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Alpixel\Bundle\CMSBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Alpixel\Bundle\SEOBundle\Entity\MetaTagPlaceholderInterface; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Page. |
11
|
|
|
* |
12
|
|
|
* @ORM\Table(name="cms_node") |
13
|
|
|
* @ORM\HasLifecycleCallbacks |
14
|
|
|
* @ORM\Entity(repositoryClass="Alpixel\Bundle\CMSBundle\Entity\Repository\NodeRepository") |
15
|
|
|
* @ORM\InheritanceType("JOINED") |
16
|
|
|
* @ORM\DiscriminatorColumn(name="type", type="string") |
17
|
|
|
* @ORM\DiscriminatorMap({}) |
18
|
|
|
*/ |
19
|
|
|
abstract class Node implements MetaTagPlaceholderInterface, TranslatableInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var int |
23
|
|
|
* |
24
|
|
|
* @ORM\Column(name="node_id", type="integer") |
25
|
|
|
* @ORM\Id |
26
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
27
|
|
|
*/ |
28
|
|
|
protected $id; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
* |
33
|
|
|
* @ORM\Column(name="locale", type="string", length=10, nullable=true) |
34
|
|
|
*/ |
35
|
|
|
protected $locale; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var \Alpixel\Bundle\CMSBundle\Entity\Node |
39
|
|
|
* |
40
|
|
|
* @ORM\ManyToOne(targetEntity="Alpixel\Bundle\CMSBundle\Entity\Node") |
41
|
|
|
* @ORM\JoinColumn(name="translation_source_id",referencedColumnName="node_id", nullable=true, onDelete="SET NULL") |
42
|
|
|
*/ |
43
|
|
|
protected $translationSource; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var string |
47
|
|
|
* |
48
|
|
|
* @ORM\Column(name="title", type="string", length=255, nullable=false) |
49
|
|
|
*/ |
50
|
|
|
protected $title; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var string |
54
|
|
|
* |
55
|
|
|
* @ORM\Column(name="content", type="text", nullable=true) |
56
|
|
|
*/ |
57
|
|
|
protected $content; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var \DateTime |
61
|
|
|
* |
62
|
|
|
* @Gedmo\Timestampable(on="create") |
63
|
|
|
* @ORM\Column(name="date_created", type="datetime", nullable=false) |
64
|
|
|
*/ |
65
|
|
|
protected $dateCreated; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var \DateTime |
69
|
|
|
* @Gedmo\Timestampable(on="update") |
70
|
|
|
* @ORM\Column(name="date_updated", type="datetime", nullable=false) |
71
|
|
|
*/ |
72
|
|
|
protected $dateUpdated; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var bool |
76
|
|
|
* |
77
|
|
|
* @ORM\Column(name="published", type="boolean", nullable=false, options={"default"= true}) |
78
|
|
|
*/ |
79
|
|
|
protected $published; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var int |
83
|
|
|
* @Gedmo\SortablePosition |
84
|
|
|
* @ORM\Column(name="position", type="integer", nullable=false) |
85
|
|
|
*/ |
86
|
|
|
protected $position; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @Gedmo\Slug(fields={"title"}, updatable=false, separator="-") |
90
|
|
|
* @ORM\Column(length=128, unique=true) |
91
|
|
|
**/ |
92
|
|
|
protected $slug; |
93
|
|
|
|
94
|
|
|
public function __construct() |
95
|
|
|
{ |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
abstract public function getType(); |
99
|
|
|
|
100
|
|
|
public function __clone() |
101
|
|
|
{ |
102
|
|
|
$this->id = null; |
103
|
|
|
$this->dateCreated = null; |
104
|
|
|
$this->dateUpdated = null; |
105
|
|
|
$this->position = null; |
106
|
|
|
$this->slug = null; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function getUriParameters() |
110
|
|
|
{ |
111
|
|
|
return [ |
112
|
|
|
'id' => $this->id, |
113
|
|
|
'slug' => $this->slug, |
114
|
|
|
]; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function getPlaceholders() |
118
|
|
|
{ |
119
|
|
|
return [ |
120
|
|
|
'[cms:title]' => $this->title, |
121
|
|
|
'[cms:resume]' => substr(strip_tags($this->content), 0, 150), |
122
|
|
|
]; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function __toString() |
126
|
|
|
{ |
127
|
|
|
return $this->title; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Gets the value of id. |
132
|
|
|
* |
133
|
|
|
* @return int |
134
|
|
|
*/ |
135
|
|
|
public function getId() |
136
|
|
|
{ |
137
|
|
|
return $this->id; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Sets the value of id. |
142
|
|
|
* |
143
|
|
|
* @param int $id the id |
144
|
|
|
* |
145
|
|
|
* @return self |
146
|
|
|
*/ |
147
|
|
|
public function setId($id) |
148
|
|
|
{ |
149
|
|
|
$this->id = $id; |
150
|
|
|
|
151
|
|
|
return $this; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Gets the value of title. |
156
|
|
|
* |
157
|
|
|
* @return string |
158
|
|
|
*/ |
159
|
|
|
public function getTitle() |
160
|
|
|
{ |
161
|
|
|
return $this->title; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Sets the value of title. |
166
|
|
|
* |
167
|
|
|
* @param string $title the title |
168
|
|
|
* |
169
|
|
|
* @return self |
170
|
|
|
*/ |
171
|
|
|
public function setTitle($title) |
172
|
|
|
{ |
173
|
|
|
$this->title = $title; |
174
|
|
|
|
175
|
|
|
return $this; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Gets the value of content. |
180
|
|
|
* |
181
|
|
|
* @return string |
182
|
|
|
*/ |
183
|
|
|
public function getContent() |
184
|
|
|
{ |
185
|
|
|
return $this->content; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* Sets the value of content. |
190
|
|
|
* |
191
|
|
|
* @param string $content the content |
192
|
|
|
* |
193
|
|
|
* @return self |
194
|
|
|
*/ |
195
|
|
|
public function setContent($content) |
196
|
|
|
{ |
197
|
|
|
$this->content = $content; |
198
|
|
|
|
199
|
|
|
return $this; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Gets the value of dateCreated. |
204
|
|
|
* |
205
|
|
|
* @return \DateTime |
206
|
|
|
*/ |
207
|
|
|
public function getDateCreated() |
208
|
|
|
{ |
209
|
|
|
return $this->dateCreated; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Sets the value of dateCreated. |
214
|
|
|
* |
215
|
|
|
* @param \DateTime $dateCreated the date created |
216
|
|
|
* |
217
|
|
|
* @return self |
218
|
|
|
*/ |
219
|
|
|
public function setDateCreated(\DateTime $dateCreated) |
220
|
|
|
{ |
221
|
|
|
$this->dateCreated = $dateCreated; |
222
|
|
|
|
223
|
|
|
return $this; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* Gets the value of dateUpdated. |
228
|
|
|
* |
229
|
|
|
* @return \DateTime |
230
|
|
|
*/ |
231
|
|
|
public function getDateUpdated() |
232
|
|
|
{ |
233
|
|
|
return $this->dateUpdated; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* Sets the value of dateUpdated. |
238
|
|
|
* |
239
|
|
|
* @param \DateTime $dateUpdated the date updated |
240
|
|
|
* |
241
|
|
|
* @return self |
242
|
|
|
*/ |
243
|
|
|
public function setDateUpdated(\DateTime $dateUpdated) |
244
|
|
|
{ |
245
|
|
|
$this->dateUpdated = $dateUpdated; |
246
|
|
|
|
247
|
|
|
return $this; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* Gets the value of published. |
252
|
|
|
* |
253
|
|
|
* @return bool |
254
|
|
|
*/ |
255
|
|
|
public function getPublished() |
256
|
|
|
{ |
257
|
|
|
return $this->published; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* Sets the value of published. |
262
|
|
|
* |
263
|
|
|
* @param bool $published the published |
264
|
|
|
* |
265
|
|
|
* @return self |
266
|
|
|
*/ |
267
|
|
|
public function setPublished($published) |
268
|
|
|
{ |
269
|
|
|
$this->published = $published; |
270
|
|
|
|
271
|
|
|
return $this; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* Gets the value of position. |
276
|
|
|
* |
277
|
|
|
* @return int |
278
|
|
|
*/ |
279
|
|
|
public function getPosition() |
280
|
|
|
{ |
281
|
|
|
return $this->position; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* Sets the value of position. |
286
|
|
|
* |
287
|
|
|
* @param int $position the position |
288
|
|
|
* |
289
|
|
|
* @return self |
290
|
|
|
*/ |
291
|
|
|
public function setPosition($position) |
292
|
|
|
{ |
293
|
|
|
$this->position = $position; |
294
|
|
|
|
295
|
|
|
return $this; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
/** |
299
|
|
|
* Gets the value of slug. |
300
|
|
|
* |
301
|
|
|
* @return mixed |
302
|
|
|
*/ |
303
|
|
|
public function getSlug() |
304
|
|
|
{ |
305
|
|
|
return $this->slug; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
/** |
309
|
|
|
* Sets the value of slug. |
310
|
|
|
* |
311
|
|
|
* @param mixed $slug the slug |
312
|
|
|
* |
313
|
|
|
* @return self |
314
|
|
|
*/ |
315
|
|
|
public function setSlug($slug) |
316
|
|
|
{ |
317
|
|
|
$this->slug = $slug; |
318
|
|
|
|
319
|
|
|
return $this; |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* Gets the value of locale. |
324
|
|
|
* |
325
|
|
|
* @return string |
326
|
|
|
*/ |
327
|
|
|
public function getLocale() |
328
|
|
|
{ |
329
|
|
|
return $this->locale; |
330
|
|
|
} |
331
|
|
|
|
332
|
|
|
/** |
333
|
|
|
* Sets the value of locale. |
334
|
|
|
* |
335
|
|
|
* @param string $locale the locale |
336
|
|
|
* |
337
|
|
|
* @return self |
338
|
|
|
*/ |
339
|
|
|
public function setLocale($locale) |
340
|
|
|
{ |
341
|
|
|
$this->locale = $locale; |
342
|
|
|
|
343
|
|
|
return $this; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* Gets the value of translationSource. |
348
|
|
|
* |
349
|
|
|
* @return \Alpixel\Bundle\CMSBundle\Entity\Node |
350
|
|
|
*/ |
351
|
|
|
public function getTranslationSource() |
352
|
|
|
{ |
353
|
|
|
return $this->translationSource; |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
/** |
357
|
|
|
* Sets the value of translationSource. |
358
|
|
|
* |
359
|
|
|
* @param \Alpixel\Bundle\CMSBundle\Entity\Node $translationSource the translation source |
360
|
|
|
* |
361
|
|
|
* @return self |
362
|
|
|
*/ |
363
|
|
|
public function setTranslationSource(\Alpixel\Bundle\CMSBundle\Entity\Node $translationSource) |
364
|
|
|
{ |
365
|
|
|
$this->translationSource = $translationSource; |
366
|
|
|
|
367
|
|
|
return $this; |
368
|
|
|
} |
369
|
|
|
} |
370
|
|
|
|