Completed
Pull Request — master (#10)
by
unknown
18:31 queued 13:00
created

PageExtendedTrait::setParentPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PiedWeb\CMSBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * Page extended: // I may cut this in multiple traits
9
 * - meta no-index
10
 * - Rich Content (meta desc, parentPage, h1, name [to do short link] )
11
 * - author (link)
12
 * - template.
13
 */
14
trait PageExtendedTrait
15
{
16
    /**
17
     * @ORM\Column(type="string", length=255, nullable=true)
18
     */
19
    protected $excrept;
20
21
    /**
22
     * @ORM\Column(type="string", length=50, nullable=true)
23
     */
24
    protected $metaRobots;
25
26
    /**
27
     * @ORM\ManyToOne(targetEntity="PiedWeb\CMSBundle\Entity\PageInterface", inversedBy="childrenPages")
28
     */
29
    protected $parentPage;
30
31
    /**
32
     * @ORM\OneToMany(targetEntity="PiedWeb\CMSBundle\Entity\PageInterface", mappedBy="parentPage")
33
     * @ORM\OrderBy({"id"                                                    = "ASC"})
34
     */
35
    protected $childrenPages;
36
37
    /**
38
     * @ORM\Column(type="string", length=255, nullable=true)
39
     */
40
    protected $h1;
41
42
    /**
43
     * @ORM\Column(type="string", length=150, nullable=true)
44
     */
45
    protected $name;
46
47 3
    public function __constructExtended()
48
    {
49 3
    }
50
51
    public function getExcrept(): ?string
52
    {
53
        return $this->excrept;
54
    }
55
56
    public function setExcrept(?string $excrept): self
57
    {
58
        $this->excrept = $excrept;
59
60
        return $this;
61
    }
62
63
    public function getMetaRobots(): ?string
64
    {
65
        return $this->metaRobots;
66
    }
67
68
    public function setMetaRobots(?string $metaRobots): self
69
    {
70
        $this->metaRobots = $metaRobots;
71
72
        return $this;
73
    }
74
75
    public function getParentPage(): ?self
76
    {
77
        return $this->parentPage;
78
    }
79
80
    public function setParentPage(?self $parentPage): self
81
    {
82
        $this->parentPage = $parentPage;
83
84
        return $this;
85
    }
86
87
    public function getChildrenPages()
88
    {
89
        return $this->childrenPages;
90
    }
91
92
    public function getH1($elseReturnTitle = false): ?string
93
    {
94
        return $this->h1 ?? (true === $elseReturnTitle ? $this->title : null);
95
    }
96
97
    public function setH1(?string $h1): self
98
    {
99
        $this->h1 = $h1;
100
101
        return $this;
102
    }
103
104
    public function getName(): ?string
105
    {
106
        return $this->name;
107
    }
108
109
    public function setName(?string $name): self
110
    {
111
        $this->name = $name;
112
113
        return $this;
114
    }
115
}
116