Passed
Push — develop ( f08141...fbab06 )
by Daniel
04:49
created

Page::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Entity\Content;
4
5
use ApiPlatform\Core\Annotation\ApiProperty;
6
use ApiPlatform\Core\Annotation\ApiResource;
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\ORM\Mapping as ORM;
9
use Silverback\ApiComponentBundle\Entity\Layout\Layout;
10
use Silverback\ApiComponentBundle\Entity\Route\RouteAwareInterface;
11
use Silverback\ApiComponentBundle\Entity\Route\RouteAwareTrait;
12
use Symfony\Component\Serializer\Annotation\Groups;
13
14
/**
15
 * Class Page
16
 * @package Silverback\ApiComponentBundle\Entity\Content
17
 * @author Daniel West <[email protected]>
18
 * @ApiResource()
19
 * @ORM\Entity()
20
 */
21
class Page extends AbstractContent implements RouteAwareInterface
22
{
23
    use RouteAwareTrait;
24
25
    /**
26
     * @ORM\Column()
27
     * @Groups({"content"})
28
     * @var string
29
     */
30
    private $title;
31
32
    /**
33
     * @ORM\Column()
34
     * @Groups({"content"})
35
     * @var string
36
     */
37
    private $metaDescription;
38
39
    /**
40
     * @ORM\ManyToOne(targetEntity="Page")
41
     * @ORM\JoinColumn(nullable=true)
42
     * @var null|Page
43
     */
44
    private $parent;
45
46
    /**
47
     * @ORM\ManyToOne(targetEntity="Silverback\ApiComponentBundle\Entity\Layout\Layout")
48
     * @ORM\JoinColumn(onDelete="SET NULL")
49
     * @ApiProperty()
50
     * @Groups({"content"})
51
     * @var Layout|null
52
     */
53
    private $layout;
54
55 3
    public function __construct()
56
    {
57 3
        parent::__construct();
58 3
        $this->routes = new ArrayCollection;
59 3
    }
60
61
    /**
62
     * @return string
63
     */
64 1
    public function getTitle(): string
65
    {
66 1
        return $this->title;
67
    }
68
69
    /**
70
     * @param string $title
71
     */
72 2
    public function setTitle(string $title): void
73
    {
74 2
        $this->title = $title;
75 2
    }
76
77
    /**
78
     * @return string
79
     */
80 1
    public function getMetaDescription(): string
81
    {
82 1
        return $this->metaDescription;
83
    }
84
85
    /**
86
     * @param string $metaDescription
87
     */
88 2
    public function setMetaDescription(string $metaDescription): void
89
    {
90 2
        $this->metaDescription = $metaDescription;
91 2
    }
92
93
    /**
94
     * @return null|Page
95
     */
96 1
    public function getParent(): ?Page
97
    {
98 1
        return $this->parent;
99
    }
100
101
    /**
102
     * @param null|Page $parent
103
     */
104 2
    public function setParent(?Page $parent): void
105
    {
106 2
        $this->parent = $parent;
107 2
    }
108
109
    /**
110
     * @return Layout|null
111
     */
112 1
    public function getLayout(): ?Layout
113
    {
114 1
        return $this->layout;
115
    }
116
117
    /**
118
     * @param Layout|null $layout
119
     */
120 2
    public function setLayout(?Layout $layout): void
121
    {
122 2
        $this->layout = $layout;
123 2
    }
124
125
    /**
126
     * @inheritdoc
127
     */
128
    public function getDefaultRoute(): string
129
    {
130
        return $this->getTitle();
131
    }
132
}
133