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