1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WebCMS\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Gedmo\Mapping\Annotation as gedmo; |
7
|
|
|
use Doctrine\orm\Mapping as orm; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @gedmo\Tree(type="nested") |
11
|
|
|
* @orm\Entity(repositoryClass="PageRepository") |
12
|
|
|
* @author Tomáš Voslař <tomas.voslar at webcook.cz> |
13
|
|
|
*/ |
14
|
|
|
class Page extends Seo |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @orm\Column(length=64) |
18
|
|
|
*/ |
19
|
|
|
private $title; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @gedmo\Slug(fields={"title"}) |
23
|
|
|
* @orm\Column(length=64, unique=true) |
24
|
|
|
*/ |
25
|
|
|
private $slug; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @gedmo\TreeLeft |
29
|
|
|
* @orm\Column(type="integer") |
30
|
|
|
*/ |
31
|
|
|
private $lft; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @gedmo\TreeRight |
35
|
|
|
* @orm\Column(type="integer") |
36
|
|
|
*/ |
37
|
|
|
private $rgt; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @gedmo\TreeParent |
41
|
|
|
* @orm\ManyToOne(targetEntity="Page", inversedBy="children") |
42
|
|
|
* @orm\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE") |
43
|
|
|
*/ |
44
|
|
|
private $parent; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @gedmo\TreeRoot |
48
|
|
|
* @orm\Column(type="integer", nullable=true) |
49
|
|
|
*/ |
50
|
|
|
private $root; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @gedmo\TreeLevel |
54
|
|
|
* @orm\Column(name="lvl", type="integer") |
55
|
|
|
*/ |
56
|
|
|
private $level; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @orm\OneToMany(targetEntity="Page", mappedBy="parent") |
60
|
|
|
*/ |
61
|
|
|
private $children; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @gedmo\Timestampable(on="create") |
65
|
|
|
* @orm\Column(type="datetime") |
66
|
|
|
*/ |
67
|
|
|
private $created; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @gedmo\Timestampable(on="update") |
71
|
|
|
* @orm\Column(type="datetime") |
72
|
|
|
*/ |
73
|
|
|
private $updated; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @orm\ManyToOne(targetEntity="Language") |
77
|
|
|
* @orm\JoinColumn(name="language_id", referencedColumnName="id", onDelete="CASCADE") |
78
|
|
|
*/ |
79
|
|
|
private $language; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @orm\ManyToOne(targetEntity="Module") |
83
|
|
|
* @orm\JoinColumn(name="module_id", referencedColumnName="id", onDelete="SET NULL", nullable=true) |
84
|
|
|
*/ |
85
|
|
|
private $module; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @orm\Column(nullable=true) |
89
|
|
|
*/ |
90
|
|
|
private $moduleName; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @orm\Column |
94
|
|
|
*/ |
95
|
|
|
private $presenter; |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @orm\Column |
99
|
|
|
*/ |
100
|
|
|
private $path; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @orm\Column(type="boolean") |
104
|
|
|
*/ |
105
|
|
|
public $visible; |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @orm\Column(type="boolean", name="`default`") |
109
|
|
|
*/ |
110
|
|
|
private $default; |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @orm\Column(type="boolean") |
114
|
|
|
*/ |
115
|
|
|
public $secured = false; |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @orm\Column |
119
|
|
|
*/ |
120
|
|
|
private $class; |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @orm\OneToMany(targetEntity="Box", mappedBy="pageTo") |
124
|
|
|
*/ |
125
|
|
|
private $boxes; |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @orm\Column(nullable=true) |
129
|
|
|
*/ |
130
|
|
|
private $redirect; |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @orm\Column(type="text", nullable=true) |
134
|
|
|
*/ |
135
|
|
|
private $layout; |
136
|
|
|
|
137
|
2 |
|
public function __construct() |
138
|
|
|
{ |
139
|
2 |
|
$this->children = new ArrayCollection(); |
140
|
2 |
|
} |
141
|
|
|
|
142
|
|
|
public function getSlug() |
143
|
|
|
{ |
144
|
|
|
return $this->slug; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
public function getId() |
148
|
|
|
{ |
149
|
|
|
return $this->id; |
150
|
|
|
} |
151
|
|
|
|
152
|
2 |
|
public function setTitle($title) |
153
|
|
|
{ |
154
|
2 |
|
$this->title = $title; |
155
|
2 |
|
} |
156
|
|
|
|
157
|
|
|
public function getTitle() |
158
|
|
|
{ |
159
|
|
|
return $this->title; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
public function setParent($parent) |
163
|
|
|
{ |
164
|
|
|
$this->parent = $parent; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
public function getParent() |
168
|
|
|
{ |
169
|
|
|
return $this->parent; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
public function getRoot() |
173
|
|
|
{ |
174
|
|
|
return $this->root; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
public function getLevel() |
178
|
|
|
{ |
179
|
|
|
return $this->level; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
public function getChildren() |
183
|
|
|
{ |
184
|
|
|
return $this->children; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
public function getLeft() |
188
|
|
|
{ |
189
|
|
|
return $this->lft; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
public function getRight() |
193
|
|
|
{ |
194
|
|
|
return $this->rgt; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
public function getCreated() |
198
|
|
|
{ |
199
|
|
|
return $this->created; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
public function getUpdated() |
203
|
|
|
{ |
204
|
|
|
return $this->updated; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
public function getLanguage() |
208
|
|
|
{ |
209
|
|
|
return $this->language; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
public function setLanguage($language) |
213
|
|
|
{ |
214
|
|
|
$this->language = $language; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public function getVisible() |
218
|
|
|
{ |
219
|
|
|
return $this->visible; |
220
|
|
|
} |
221
|
|
|
|
222
|
2 |
|
public function setVisible($visible) |
223
|
|
|
{ |
224
|
2 |
|
$this->visible = $visible; |
225
|
2 |
|
} |
226
|
|
|
|
227
|
|
|
public function getDefault() |
228
|
|
|
{ |
229
|
|
|
return $this->default; |
230
|
|
|
} |
231
|
|
|
|
232
|
2 |
|
public function setDefault($default) |
233
|
|
|
{ |
234
|
2 |
|
$this->default = $default; |
235
|
2 |
|
} |
236
|
|
|
|
237
|
|
|
public function getSecured() |
238
|
|
|
{ |
239
|
|
|
return $this->secured; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
public function setSecured($secured) |
243
|
|
|
{ |
244
|
|
|
$this->secured = $secured; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
public function getModule() |
248
|
|
|
{ |
249
|
|
|
return $this->module; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
public function setModule($module) |
253
|
|
|
{ |
254
|
|
|
$this->module = $module; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
public function getPresenter() |
258
|
|
|
{ |
259
|
|
|
return $this->presenter; |
260
|
|
|
} |
261
|
|
|
|
262
|
2 |
|
public function setPresenter($presenter) |
263
|
|
|
{ |
264
|
2 |
|
$this->presenter = $presenter; |
265
|
2 |
|
} |
266
|
|
|
|
267
|
|
|
public function getModuleName() |
268
|
|
|
{ |
269
|
|
|
return $this->moduleName; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
public function setModuleName($moduleName) |
273
|
|
|
{ |
274
|
|
|
$this->moduleName = $moduleName; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
public function getPath() |
278
|
|
|
{ |
279
|
|
|
return $this->path; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* @param string $path |
284
|
|
|
*/ |
285
|
2 |
|
public function setPath($path) |
286
|
|
|
{ |
287
|
2 |
|
$this->path = $path; |
288
|
2 |
|
} |
289
|
|
|
|
290
|
|
|
public function getClass() |
291
|
|
|
{ |
292
|
|
|
return $this->class; |
293
|
|
|
} |
294
|
|
|
|
295
|
2 |
|
public function setClass($class) |
296
|
|
|
{ |
297
|
2 |
|
$this->class = $class; |
298
|
2 |
|
} |
299
|
|
|
|
300
|
|
|
public function __toString() |
301
|
|
|
{ |
302
|
|
|
return $this->getTitle(); |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
public function getBoxes() |
306
|
|
|
{ |
307
|
|
|
return $this->boxes; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
/** |
311
|
|
|
* @param Box[] $boxes |
312
|
|
|
*/ |
313
|
|
|
public function setBoxes($boxes) |
314
|
|
|
{ |
315
|
|
|
$this->boxes = $boxes; |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
public function getBox($name) |
319
|
|
|
{ |
320
|
|
|
foreach ($this->boxes as $box) { |
321
|
|
|
if ($box->getBox() === $name) { |
322
|
|
|
return $box; |
323
|
|
|
} |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
return NULL; |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
/** |
330
|
|
|
* @param string $slug |
331
|
|
|
*/ |
332
|
|
|
public function setSlug($slug) |
333
|
|
|
{ |
334
|
|
|
$this->slug = $slug; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
public function getRedirect() |
338
|
|
|
{ |
339
|
|
|
return $this->redirect; |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
/** |
343
|
|
|
* @param boolean $redirect |
344
|
|
|
*/ |
345
|
|
|
public function setRedirect($redirect) |
346
|
|
|
{ |
347
|
|
|
$this->redirect = $redirect; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* Gets the value of layout. |
352
|
|
|
* |
353
|
|
|
* @return mixed |
354
|
|
|
*/ |
355
|
|
|
public function getLayout() |
356
|
|
|
{ |
357
|
|
|
return $this->layout; |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* Sets the value of layout. |
362
|
|
|
* |
363
|
|
|
* @param mixed $layout the layout |
364
|
|
|
* |
365
|
|
|
* @return self |
366
|
|
|
*/ |
367
|
|
|
public function setLayout($layout) |
368
|
|
|
{ |
369
|
|
|
$this->layout = $layout; |
370
|
|
|
|
371
|
|
|
return $this; |
372
|
|
|
} |
373
|
|
|
} |
374
|
|
|
|