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