Test Failed
Push — develop ( b13210...c32797 )
by Daniel
04:26
created

AbstractDynamicPage::isDynamic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity\Content\Page\Dynamic;
4
5
use ApiPlatform\Core\Annotation\ApiProperty;
6
use Doctrine\ORM\Mapping as ORM;
7
use Silverback\ApiComponentBundle\Entity\Content\Page\AbstractPage;
8
use Silverback\ApiComponentBundle\Entity\Route\Route;
9
use Symfony\Component\Serializer\Annotation\Groups;
10
11
/**
12
 * Class AbstractDynamicPage
13
 * @package Silverback\ApiComponentBundle\Entity\Content\Page\Dynamic
14
 * @ORM\Entity()
15
 */
16
abstract class AbstractDynamicPage extends AbstractPage
17
{
18
    /** @Groups({"dynamic_content", "route"}) */
19
    protected $componentLocations;
20
21
    /**
22
     * @ORM\ManyToOne(targetEntity="Silverback\ApiComponentBundle\Entity\Route\Route")
23
     * @ORM\JoinColumn(nullable=true, referencedColumnName="route", onDelete="SET NULL")
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
    /**
35
     * @param null|Route $parentRoute
36
     */
37
    public function setParentRoute(?Route $parentRoute): void
38
    {
39
        $this->parentRoute = $parentRoute;
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45
    public function getParentRoute(): ?Route
46
    {
47
        if ($this->parentRoute) {
48
            return $this->parentRoute;
49
        }
50
        if ($this->nested) {
51
            return parent::getParentRoute();
52
        }
53
        return null;
54
    }
55
56
    /**
57
     * @return bool
58
     */
59
    public function isNested(): bool
60
    {
61
        return $this->nested;
62
    }
63
64
    /**
65
     * @param bool $nested
66
     */
67
    public function setNested(bool $nested): void
68
    {
69
        $this->nested = $nested;
70
    }
71
72
    /**
73
     * @ApiProperty()
74
     * @Groups({"content","route"})
75
     */
76
    public function isDynamic(): bool
77
    {
78
        return true;
79
    }
80
}
81