1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Victoire\Bundle\CoreBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
8
|
|
|
use JMS\Serializer\Annotation as Serializer; |
9
|
|
|
use Knp\DoctrineBehaviors\Model\Translatable\Translatable; |
10
|
|
|
use Symfony\Component\PropertyAccess\PropertyAccess; |
11
|
|
|
use Victoire\Bundle\BusinessPageBundle\Entity\VirtualBusinessPage; |
12
|
|
|
use Victoire\Bundle\TemplateBundle\Entity\Template; |
13
|
|
|
use Victoire\Bundle\ViewReferenceBundle\ViewReference\ViewReference; |
14
|
|
|
use Victoire\Bundle\WidgetBundle\Entity\Widget; |
15
|
|
|
use Victoire\Bundle\WidgetMapBundle\Entity\WidgetMap; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Victoire View |
19
|
|
|
* A victoire view is a visual representation with a widget map. |
20
|
|
|
* |
21
|
|
|
* @Gedmo\Tree(type="nested") |
22
|
|
|
* @ORM\InheritanceType("SINGLE_TABLE") |
23
|
|
|
* @ORM\DiscriminatorColumn(name="type", type="string") |
24
|
|
|
* @ORM\Entity( |
25
|
|
|
* repositoryClass="Victoire\Bundle\CoreBundle\Repository\ViewRepository" |
26
|
|
|
* ) |
27
|
|
|
* @ORM\Table("vic_view") |
28
|
|
|
* @ORM\HasLifecycleCallbacks |
29
|
|
|
*/ |
30
|
|
|
abstract class View |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
use \Gedmo\Timestampable\Traits\TimestampableEntity; |
33
|
|
|
use Translatable; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @Serializer\Groups({"search"}) |
37
|
|
|
*/ |
38
|
|
|
protected $translations; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var int |
42
|
|
|
* |
43
|
|
|
* @ORM\Column(name="id", type="integer") |
44
|
|
|
* @ORM\Id |
45
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
46
|
|
|
*/ |
47
|
|
|
protected $id; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var string |
51
|
|
|
* |
52
|
|
|
* @ORM\Column(name="bodyId", type="string", length=255, nullable=true) |
53
|
|
|
*/ |
54
|
|
|
protected $bodyId; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var string |
58
|
|
|
* |
59
|
|
|
* @ORM\Column(name="bodyClass", type="string", length=255, nullable=true) |
60
|
|
|
*/ |
61
|
|
|
protected $bodyClass; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var [WidgetMap] |
65
|
|
|
* |
66
|
|
|
* @ORM\OneToMany(targetEntity="\Victoire\Bundle\WidgetMapBundle\Entity\WidgetMap", mappedBy="view", orphanRemoval=true, cascade={"persist", "remove"}) |
67
|
|
|
*/ |
68
|
|
|
protected $widgetMaps = []; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @Gedmo\TreeParent |
72
|
|
|
* @ORM\ManyToOne(targetEntity="View", inversedBy="children", cascade={"persist"}) |
73
|
|
|
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL") |
74
|
|
|
*/ |
75
|
|
|
protected $parent; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @var int |
79
|
|
|
* |
80
|
|
|
* @ORM\Column(name="position", type="integer", nullable=false) |
81
|
|
|
*/ |
82
|
|
|
protected $position = 0; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @Gedmo\TreeLeft |
86
|
|
|
* @ORM\Column(name="lft", type="integer") |
87
|
|
|
*/ |
88
|
|
|
protected $lft; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @Gedmo\TreeLevel |
92
|
|
|
* @ORM\Column(name="lvl", type="integer") |
93
|
|
|
*/ |
94
|
|
|
protected $lvl; |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @Gedmo\TreeRight |
98
|
|
|
* @ORM\Column(name="rgt", type="integer") |
99
|
|
|
*/ |
100
|
|
|
protected $rgt; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @Gedmo\TreeRoot |
104
|
|
|
* @ORM\Column(name="root", type="integer", nullable=true) |
105
|
|
|
*/ |
106
|
|
|
protected $root; |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @ORM\OneToMany(targetEntity="View", mappedBy="parent", cascade={"remove", "persist"}) |
110
|
|
|
* @ORM\OrderBy({"lft" = "ASC"}) |
111
|
|
|
*/ |
112
|
|
|
protected $children = []; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* This relation is dynamicly added by PageSubscriber. |
116
|
|
|
*/ |
117
|
|
|
protected $author; |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @var string |
121
|
|
|
* |
122
|
|
|
* @ORM\Column(name="undeletable", type="boolean") |
123
|
|
|
*/ |
124
|
|
|
protected $undeletable = false; |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @var ViewReference[] |
128
|
|
|
* The reference is related to viewsReferences.xml file which list all app views. |
129
|
|
|
* This is used to speed up the routing system and identify virtual pages (BusinessPage). |
130
|
|
|
*/ |
131
|
|
|
protected $references; |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @var string |
135
|
|
|
* |
136
|
|
|
* @ORM\ManyToOne(targetEntity="\Victoire\Bundle\TemplateBundle\Entity\Template", inversedBy="inheritors", cascade={"persist"}) |
137
|
|
|
* @ORM\JoinColumn(name="template_id", referencedColumnName="id", onDelete="CASCADE") |
138
|
|
|
*/ |
139
|
|
|
protected $template; |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @var string |
143
|
|
|
* |
144
|
|
|
* @ORM\Column(name="cssHash", type="string", length=40 ,nullable=true) |
145
|
|
|
*/ |
146
|
|
|
protected $cssHash; |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @deprecated |
150
|
|
|
* @ORM\Column(name="widget_map", type="array") |
151
|
|
|
*/ |
152
|
|
|
protected $widgetMap = []; |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @var string |
156
|
|
|
* |
157
|
|
|
* @ORM\OneToMany(targetEntity="\Victoire\Bundle\WidgetBundle\Entity\Widget", mappedBy="view", cascade={"persist", "remove"}) |
158
|
|
|
* @ORM\OrderBy({"id" = "ASC"}) |
159
|
|
|
*/ |
160
|
|
|
protected $widgets; |
161
|
|
|
/** |
162
|
|
|
* @var bool |
163
|
|
|
* |
164
|
|
|
* @ORM\Column(name="cssUpToDate", type="boolean") |
165
|
|
|
*/ |
166
|
|
|
protected $cssUpToDate = false; |
167
|
|
|
/** |
168
|
|
|
* @var bool |
169
|
|
|
* |
170
|
|
|
* @ORM\Column(name="roles", type="text", nullable=true) |
171
|
|
|
*/ |
172
|
|
|
protected $roles; |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @var array |
176
|
|
|
*/ |
177
|
|
|
protected $builtWidgetMap; |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* Construct. |
181
|
|
|
**/ |
182
|
|
|
public function __construct() |
183
|
|
|
{ |
184
|
|
|
$this->children = new ArrayCollection(); |
|
|
|
|
185
|
|
|
$this->widgetMaps = new ArrayCollection(); |
|
|
|
|
186
|
|
|
$this->references = []; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* to string. |
191
|
|
|
* |
192
|
|
|
* @return string |
193
|
|
|
**/ |
194
|
|
|
public function __toString() |
195
|
|
|
{ |
196
|
|
|
return '#'.$this->getId().' '.$this->getName(); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* Get id. |
201
|
|
|
* |
202
|
|
|
* @return int |
203
|
|
|
*/ |
204
|
|
|
public function getId() |
205
|
|
|
{ |
206
|
|
|
return $this->id; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* Set id. |
211
|
|
|
* |
212
|
|
|
* @param id $id |
213
|
|
|
*/ |
214
|
|
|
public function setId($id) |
215
|
|
|
{ |
216
|
|
|
$this->id = $id; |
|
|
|
|
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* Set template. |
221
|
|
|
* |
222
|
|
|
* @param View $template |
223
|
|
|
* |
224
|
|
|
* @return View |
225
|
|
|
*/ |
226
|
|
|
public function setTemplate($template) |
227
|
|
|
{ |
228
|
|
|
$this->template = $template; |
|
|
|
|
229
|
|
|
|
230
|
|
|
return $this; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Get template. |
235
|
|
|
* |
236
|
|
|
* @return View |
237
|
|
|
*/ |
238
|
|
|
public function getTemplate() |
239
|
|
|
{ |
240
|
|
|
return $this->template; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* Set parent. |
245
|
|
|
* |
246
|
|
|
* @param View $parent |
247
|
|
|
*/ |
248
|
|
|
public function setParent(View $parent = null) |
249
|
|
|
{ |
250
|
|
|
$this->parent = $parent; |
251
|
|
|
if ($parent && !($this instanceof VirtualBusinessPage)) { |
252
|
|
|
$parent->addChild($this); |
253
|
|
|
} |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* Get parent. |
258
|
|
|
* |
259
|
|
|
* @return View parent |
260
|
|
|
*/ |
261
|
|
|
public function getParent() |
262
|
|
|
{ |
263
|
|
|
return $this->parent; |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
/** |
267
|
|
|
* Set children. |
268
|
|
|
* |
269
|
|
|
* @param View[] $children |
270
|
|
|
* |
271
|
|
|
* @return View |
272
|
|
|
*/ |
273
|
|
|
public function setChildren($children) |
274
|
|
|
{ |
275
|
|
|
$this->children = $children; |
276
|
|
|
if ($children !== null) { |
277
|
|
|
foreach ($children as $child) { |
278
|
|
|
$child->setParent($this); |
279
|
|
|
} |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
return $this; |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* Get children. |
287
|
|
|
* |
288
|
|
|
* @return View[] |
289
|
|
|
*/ |
290
|
|
|
public function getChildren() |
291
|
|
|
{ |
292
|
|
|
return $this->children; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* Has children. |
297
|
|
|
* |
298
|
|
|
* @return int |
299
|
|
|
*/ |
300
|
|
|
public function hasChildren() |
301
|
|
|
{ |
302
|
|
|
return count($this->children); |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* Add child. |
307
|
|
|
* |
308
|
|
|
* @param View $child |
309
|
|
|
*/ |
310
|
|
|
public function addChild(View $child) |
311
|
|
|
{ |
312
|
|
|
$this->children[] = $child; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* Remove child. |
317
|
|
|
* |
318
|
|
|
* @param View $child |
319
|
|
|
*/ |
320
|
|
|
public function removeChild(View $child) |
321
|
|
|
{ |
322
|
|
|
$this->children->removeElement($child); |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* Get the left value. |
327
|
|
|
* |
328
|
|
|
* @return int |
329
|
|
|
*/ |
330
|
|
|
public function getLft() |
331
|
|
|
{ |
332
|
|
|
return $this->lft; |
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* Set the left value. |
337
|
|
|
* |
338
|
|
|
* @param int $lft |
339
|
|
|
*/ |
340
|
|
|
public function setLft($lft) |
341
|
|
|
{ |
342
|
|
|
$this->lft = $lft; |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
/** |
346
|
|
|
* Get the right value. |
347
|
|
|
* |
348
|
|
|
* @return int |
349
|
|
|
*/ |
350
|
|
|
public function getRgt() |
351
|
|
|
{ |
352
|
|
|
return $this->rgt; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* Set the right value. |
357
|
|
|
* |
358
|
|
|
* @param int $rgt |
359
|
|
|
*/ |
360
|
|
|
public function setRgt($rgt) |
361
|
|
|
{ |
362
|
|
|
$this->rgt = $rgt; |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
/** |
366
|
|
|
* Get the level value. |
367
|
|
|
* |
368
|
|
|
* @return int |
369
|
|
|
*/ |
370
|
|
|
public function getLvl() |
371
|
|
|
{ |
372
|
|
|
return $this->lvl; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
/** |
376
|
|
|
* Set the level value. |
377
|
|
|
* |
378
|
|
|
* @param int $lvl |
379
|
|
|
*/ |
380
|
|
|
public function setLvl($lvl) |
381
|
|
|
{ |
382
|
|
|
$this->lvl = $lvl; |
383
|
|
|
} |
384
|
|
|
|
385
|
|
|
/** |
386
|
|
|
* Get the root value. |
387
|
|
|
* |
388
|
|
|
* @return int |
389
|
|
|
*/ |
390
|
|
|
public function getRoot() |
391
|
|
|
{ |
392
|
|
|
return $this->root; |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* Set the root value. |
397
|
|
|
* |
398
|
|
|
* @param int $root |
399
|
|
|
*/ |
400
|
|
|
public function setRoot($root) |
401
|
|
|
{ |
402
|
|
|
$this->root = $root; |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* Set undeletable. |
407
|
|
|
* |
408
|
|
|
* @param bool $undeletable |
409
|
|
|
* |
410
|
|
|
* @return View The current instance |
411
|
|
|
*/ |
412
|
|
|
public function setUndeletable($undeletable) |
413
|
|
|
{ |
414
|
|
|
$this->undeletable = $undeletable; |
|
|
|
|
415
|
|
|
|
416
|
|
|
return $this; |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* Is the widget is undeletable. |
421
|
|
|
* |
422
|
|
|
* @return string |
423
|
|
|
*/ |
424
|
|
|
public function isUndeletable() |
425
|
|
|
{ |
426
|
|
|
return $this->undeletable; |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* Get author. |
431
|
|
|
* |
432
|
|
|
* @return string |
433
|
|
|
*/ |
434
|
|
|
public function getAuthor() |
435
|
|
|
{ |
436
|
|
|
return $this->author; |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
/** |
440
|
|
|
* Set author. |
441
|
|
|
* |
442
|
|
|
* @param string $author |
443
|
|
|
* |
444
|
|
|
* @return $this |
445
|
|
|
*/ |
446
|
|
|
public function setAuthor($author) |
447
|
|
|
{ |
448
|
|
|
$this->author = $author; |
449
|
|
|
|
450
|
|
|
return $this; |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
/** |
454
|
|
|
* Get bodyId. |
455
|
|
|
* |
456
|
|
|
* @return string |
457
|
|
|
*/ |
458
|
|
|
public function getBodyId() |
459
|
|
|
{ |
460
|
|
|
return $this->bodyId; |
461
|
|
|
} |
462
|
|
|
|
463
|
|
|
/** |
464
|
|
|
* Set bodyId. |
465
|
|
|
* |
466
|
|
|
* @param string $bodyId |
467
|
|
|
* |
468
|
|
|
* @return $this |
469
|
|
|
*/ |
470
|
|
|
public function setBodyId($bodyId) |
471
|
|
|
{ |
472
|
|
|
$this->bodyId = $bodyId; |
473
|
|
|
|
474
|
|
|
return $this; |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
/** |
478
|
|
|
* Get bodyClass. |
479
|
|
|
* |
480
|
|
|
* @return string |
481
|
|
|
*/ |
482
|
|
|
public function getBodyClass() |
483
|
|
|
{ |
484
|
|
|
return $this->bodyClass; |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* Set bodyClass. |
489
|
|
|
* |
490
|
|
|
* @param string $bodyClass |
491
|
|
|
* |
492
|
|
|
* @return $this |
493
|
|
|
*/ |
494
|
|
|
public function setBodyClass($bodyClass) |
495
|
|
|
{ |
496
|
|
|
$this->bodyClass = $bodyClass; |
497
|
|
|
|
498
|
|
|
return $this; |
499
|
|
|
} |
500
|
|
|
|
501
|
|
|
/** |
502
|
|
|
* Set widgets. |
503
|
|
|
* |
504
|
|
|
* @param [WidgetMap] $widgetMaps |
|
|
|
|
505
|
|
|
* |
506
|
|
|
* @return View |
507
|
|
|
*/ |
508
|
|
|
public function setWidgetMaps($widgetMaps) |
509
|
|
|
{ |
510
|
|
|
$this->widgetMaps = $widgetMaps; |
511
|
|
|
|
512
|
|
|
return $this; |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
/** |
516
|
|
|
* Get WidgetMaps. |
517
|
|
|
* |
518
|
|
|
* @return WidgetMap[] |
519
|
|
|
*/ |
520
|
|
|
public function getWidgetMaps() |
521
|
|
|
{ |
522
|
|
|
return $this->widgetMaps; |
523
|
|
|
} |
524
|
|
|
|
525
|
|
|
/** |
526
|
|
|
* Add WidgetMap. |
527
|
|
|
* |
528
|
|
|
* @param WidgetMap $widgetMap |
529
|
|
|
*/ |
530
|
|
|
public function addWidgetMap(WidgetMap $widgetMap) |
531
|
|
|
{ |
532
|
|
|
if (!$widgetMap->getView()) { |
533
|
|
|
$widgetMap->setView($this); |
534
|
|
|
} |
535
|
|
|
$this->widgetMaps[] = $widgetMap; |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
/** |
539
|
|
|
* Remove a widgetMap. |
540
|
|
|
* |
541
|
|
|
* @param WidgetMap $widgetMap |
542
|
|
|
*/ |
543
|
|
|
public function removeWidgetMap(WidgetMap $widgetMap) |
544
|
|
|
{ |
545
|
|
|
$this->widgetMaps->removeElement($widgetMap); |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
/** |
549
|
|
|
* Get WidgetMaps for View and its Templates. |
550
|
|
|
* |
551
|
|
|
* @return WidgetMap[] |
552
|
|
|
*/ |
553
|
|
|
public function getWidgetMapsForViewAndTemplates() |
554
|
|
|
{ |
555
|
|
|
$widgetMaps = []; |
556
|
|
|
|
557
|
|
|
foreach ($this->getWidgetMaps() as $_widgetMap) { |
558
|
|
|
$widgetMaps[] = $_widgetMap; |
559
|
|
|
} |
560
|
|
|
|
561
|
|
|
if ($template = $this->getTemplate()) { |
562
|
|
|
$templateWidgetMaps = $template->getWidgetMapsForViewAndTemplates(); |
563
|
|
|
$widgetMaps = array_merge($widgetMaps, $templateWidgetMaps); |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
return $widgetMaps; |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
/** |
570
|
|
|
* Get builtWidgetMap. |
571
|
|
|
* |
572
|
|
|
* @return array |
573
|
|
|
*/ |
574
|
|
|
public function getBuiltWidgetMap() |
575
|
|
|
{ |
576
|
|
|
return $this->builtWidgetMap; |
577
|
|
|
} |
578
|
|
|
|
579
|
|
|
/** |
580
|
|
|
* Set builtWidgetMap. |
581
|
|
|
* |
582
|
|
|
* @param array $builtWidgetMap |
583
|
|
|
* |
584
|
|
|
* @return $this |
585
|
|
|
*/ |
586
|
|
|
public function setBuiltWidgetMap($builtWidgetMap) |
587
|
|
|
{ |
588
|
|
|
$this->builtWidgetMap = $builtWidgetMap; |
589
|
|
|
|
590
|
|
|
return $this; |
591
|
|
|
} |
592
|
|
|
|
593
|
|
|
/** |
594
|
|
|
* Get discriminator type. |
595
|
|
|
* |
596
|
|
|
* @return int |
597
|
|
|
*/ |
598
|
|
|
public function getType() |
599
|
|
|
{ |
600
|
|
|
$class = get_called_class(); |
601
|
|
|
|
602
|
|
|
return $class::TYPE; |
603
|
|
|
} |
604
|
|
|
|
605
|
|
|
/** |
606
|
|
|
* Set position. |
607
|
|
|
* |
608
|
|
|
* @param int $position |
609
|
|
|
*/ |
610
|
|
|
public function setPosition($position) |
611
|
|
|
{ |
612
|
|
|
$this->position = $position; |
613
|
|
|
} |
614
|
|
|
|
615
|
|
|
/** |
616
|
|
|
* Get position. |
617
|
|
|
* |
618
|
|
|
* @return int |
619
|
|
|
*/ |
620
|
|
|
public function getPosition() |
621
|
|
|
{ |
622
|
|
|
return $this->position; |
623
|
|
|
} |
624
|
|
|
|
625
|
|
|
/** |
626
|
|
|
* Get reference according to the current locale. |
627
|
|
|
* |
628
|
|
|
* @param string $locale |
629
|
|
|
* |
630
|
|
|
* @return null|ViewReference |
631
|
|
|
*/ |
632
|
|
|
public function getReference($locale = null) |
633
|
|
|
{ |
634
|
|
|
/** @var string $locale */ |
635
|
|
|
$locale = $locale ?: $this->getCurrentLocale(); |
636
|
|
|
if (is_array($this->references) && isset($this->references[$locale])) { |
637
|
|
|
return $this->references[$locale]; |
638
|
|
|
} |
639
|
|
|
} |
640
|
|
|
|
641
|
|
|
/** |
642
|
|
|
* Get references. |
643
|
|
|
* |
644
|
|
|
* @return ViewReference[] |
645
|
|
|
*/ |
646
|
|
|
public function getReferences() |
647
|
|
|
{ |
648
|
|
|
return $this->references; |
649
|
|
|
} |
650
|
|
|
|
651
|
|
|
/** |
652
|
|
|
* Set references. |
653
|
|
|
* |
654
|
|
|
* @param ViewReference[] $references |
655
|
|
|
* |
656
|
|
|
* @return $this |
657
|
|
|
*/ |
658
|
|
|
public function setReferences($references) |
659
|
|
|
{ |
660
|
|
|
$this->references = $references; |
661
|
|
|
|
662
|
|
|
return $this; |
663
|
|
|
} |
664
|
|
|
|
665
|
|
|
/** |
666
|
|
|
* Set reference. |
667
|
|
|
* |
668
|
|
|
* @param ViewReference $reference |
669
|
|
|
* @param string $locale |
670
|
|
|
* |
671
|
|
|
* @return $this |
672
|
|
|
*/ |
673
|
|
|
public function setReference(ViewReference $reference = null, $locale = null) |
674
|
|
|
{ |
675
|
|
|
/** @var string $locale */ |
676
|
|
|
$locale = $locale ?: $this->getCurrentLocale(); |
677
|
|
|
$this->references[$locale] = $reference; |
678
|
|
|
|
679
|
|
|
return $this; |
680
|
|
|
} |
681
|
|
|
|
682
|
|
|
/** |
683
|
|
|
* Get CSS hash. |
684
|
|
|
* |
685
|
|
|
* @return string |
686
|
|
|
*/ |
687
|
|
|
public function getCssHash() |
688
|
|
|
{ |
689
|
|
|
return $this->cssHash; |
690
|
|
|
} |
691
|
|
|
|
692
|
|
|
/** |
693
|
|
|
* Set CSS hash. |
694
|
|
|
* |
695
|
|
|
* @param string $cssHash |
696
|
|
|
* |
697
|
|
|
* @return $this |
698
|
|
|
*/ |
699
|
|
|
public function setCssHash($cssHash) |
700
|
|
|
{ |
701
|
|
|
$this->cssHash = $cssHash; |
702
|
|
|
|
703
|
|
|
return $this; |
704
|
|
|
} |
705
|
|
|
|
706
|
|
|
/** |
707
|
|
|
* Change cssHash. |
708
|
|
|
*/ |
709
|
|
|
public function changeCssHash() |
710
|
|
|
{ |
711
|
|
|
$this->cssHash = sha1(uniqid()); |
712
|
|
|
} |
713
|
|
|
|
714
|
|
|
/** |
715
|
|
|
* @deprecated |
716
|
|
|
* Get widgetMap |
717
|
|
|
* |
718
|
|
|
* @return widgetMap |
719
|
|
|
*/ |
720
|
|
|
public function getWidgetMap() |
721
|
|
|
{ |
722
|
|
|
return $this->widgetMap; |
|
|
|
|
723
|
|
|
} |
724
|
|
|
|
725
|
|
|
/** |
726
|
|
|
* @deprecated |
727
|
|
|
* Get widgets |
728
|
|
|
* |
729
|
|
|
* @return string |
730
|
|
|
*/ |
731
|
|
|
public function getWidgets() |
732
|
|
|
{ |
733
|
|
|
return $this->widgets; |
734
|
|
|
} |
735
|
|
|
|
736
|
|
|
/** |
737
|
|
|
* @param View $view |
738
|
|
|
* |
739
|
|
|
* @return bool |
740
|
|
|
*/ |
741
|
|
|
public function isTemplateOf(View $view) |
742
|
|
|
{ |
743
|
|
|
while ($_view = $view->getTemplate()) { |
744
|
|
|
if ($this === $_view) { |
745
|
|
|
return true; |
746
|
|
|
} |
747
|
|
|
$view = $_view; |
748
|
|
|
} |
749
|
|
|
|
750
|
|
|
return false; |
751
|
|
|
} |
752
|
|
|
|
753
|
|
|
/** |
754
|
|
|
* Get cssUpToDate. |
755
|
|
|
* |
756
|
|
|
* @return bool |
757
|
|
|
*/ |
758
|
|
|
public function isCssUpToDate() |
759
|
|
|
{ |
760
|
|
|
return $this->cssUpToDate; |
761
|
|
|
} |
762
|
|
|
|
763
|
|
|
/** |
764
|
|
|
* Set CssUpToDate. |
765
|
|
|
* |
766
|
|
|
* @param bool $cssUpToDate |
767
|
|
|
* |
768
|
|
|
* @return $this |
769
|
|
|
*/ |
770
|
|
|
public function setCssUpToDate($cssUpToDate) |
771
|
|
|
{ |
772
|
|
|
$this->cssUpToDate = $cssUpToDate; |
773
|
|
|
|
774
|
|
|
return $this; |
775
|
|
|
} |
776
|
|
|
|
777
|
|
|
/** |
778
|
|
|
* {@inheritdoc} |
779
|
|
|
*/ |
780
|
|
|
public static function getTranslationEntityClass() |
781
|
|
|
{ |
782
|
|
|
return '\\Victoire\\Bundle\\I18nBundle\\Entity\\ViewTranslation'; |
783
|
|
|
} |
784
|
|
|
|
785
|
|
|
public function getName() |
|
|
|
|
786
|
|
|
{ |
787
|
|
|
return PropertyAccess::createPropertyAccessor()->getValue($this->translate(null, false), 'getName'); |
788
|
|
|
} |
789
|
|
|
|
790
|
|
|
public function setName($name, $locale = null) |
|
|
|
|
791
|
|
|
{ |
792
|
|
|
$this->translate($locale, false)->setName($name); |
|
|
|
|
793
|
|
|
$this->mergeNewTranslations(); |
794
|
|
|
} |
795
|
|
|
|
796
|
|
|
public function getSlug() |
|
|
|
|
797
|
|
|
{ |
798
|
|
|
return PropertyAccess::createPropertyAccessor()->getValue($this->translate(null, false), 'getSlug'); |
799
|
|
|
} |
800
|
|
|
|
801
|
|
|
public function setSlug($slug, $locale = null) |
|
|
|
|
802
|
|
|
{ |
803
|
|
|
$this->translate($locale, false)->setSlug($slug); |
|
|
|
|
804
|
|
|
$this->mergeNewTranslations(); |
805
|
|
|
} |
806
|
|
|
|
807
|
|
|
/** |
808
|
|
|
* @return array |
809
|
|
|
*/ |
810
|
|
|
public function getRoles() |
811
|
|
|
{ |
812
|
|
|
return $this->roles; |
813
|
|
|
} |
814
|
|
|
|
815
|
|
|
/** |
816
|
|
|
* @param array $roles |
817
|
|
|
*/ |
818
|
|
|
public function setRoles($roles) |
819
|
|
|
{ |
820
|
|
|
$this->roles = $roles; |
|
|
|
|
821
|
|
|
} |
822
|
|
|
} |
823
|
|
|
|