|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Silverback\ApiComponentBundle\Entity\Content\Dynamic; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
7
|
|
|
use Silverback\ApiComponentBundle\Entity\Content\AbstractContent; |
|
8
|
|
|
use Silverback\ApiComponentBundle\Entity\Content\PageTrait; |
|
9
|
|
|
use Silverback\ApiComponentBundle\Entity\Route\Route; |
|
10
|
|
|
use Silverback\ApiComponentBundle\Entity\Route\RouteAwareInterface; |
|
11
|
|
|
use Silverback\ApiComponentBundle\Entity\Route\RouteAwareTrait; |
|
12
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
13
|
|
|
|
|
14
|
|
|
abstract class AbstractDynamicPage extends AbstractContent implements RouteAwareInterface |
|
15
|
|
|
{ |
|
16
|
|
|
use RouteAwareTrait; |
|
17
|
|
|
use PageTrait { |
|
18
|
|
|
getParentRoute as getParentParentRoute; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @ORM\ManyToOne(targetEntity="Silverback\ApiComponentBundle\Entity\Route\Route") |
|
23
|
|
|
* @ORM\JoinColumn(nullable=true, referencedColumnName="route") |
|
24
|
|
|
* @var Route|null |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $parentRoute; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @ORM\Column(type="boolean", options={"default":"0"}) |
|
30
|
|
|
* @var boolean |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $nested = false; |
|
33
|
|
|
|
|
34
|
|
|
/** @Groups({"dynamic_content", "route"}) */ |
|
35
|
|
|
protected $componentLocations; |
|
36
|
|
|
|
|
37
|
3 |
|
public function __construct() |
|
38
|
|
|
{ |
|
39
|
3 |
|
parent::__construct(); |
|
40
|
3 |
|
$this->routes = new ArrayCollection; |
|
41
|
3 |
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param null|Route $parentRoute |
|
45
|
|
|
*/ |
|
46
|
|
|
public function setParentRoute(?Route $parentRoute): void |
|
47
|
|
|
{ |
|
48
|
|
|
$this->parentRoute = $parentRoute; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @inheritdoc |
|
53
|
|
|
*/ |
|
54
|
2 |
|
public function getParentRoute(): ?Route |
|
55
|
|
|
{ |
|
56
|
2 |
|
if ($this->parentRoute) { |
|
57
|
|
|
return $this->parentRoute; |
|
58
|
|
|
} |
|
59
|
2 |
|
if ($this->nested) { |
|
60
|
|
|
return $this->getParentParentRoute(); |
|
61
|
|
|
} |
|
62
|
2 |
|
return null; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return bool |
|
67
|
|
|
*/ |
|
68
|
|
|
public function isNested(): bool |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->nested; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param bool $nested |
|
75
|
|
|
*/ |
|
76
|
|
|
public function setNested(bool $nested): void |
|
77
|
|
|
{ |
|
78
|
|
|
$this->nested = $nested; |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|