Completed
Push — master ( 59b92d...81b834 )
by Dev
04:01
created

PageExtendedTrait::getRelatedPages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace PiedWeb\CMSBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\Common\Collections\Collection;
7
use Doctrine\ORM\Mapping as ORM;
8
use Gedmo\Mapping\Annotation as Gedmo;
9
10
/**
11
 * Page extended: // I may cut this in multiple traits
12
 * - meta no-index
13
 * - Rich Content (meta desc, parentPage, h1, name [to do short link] )
14
 * - RelatedPages
15
 * - author (link)
16
 * - template.
17
 */
18
trait PageExtendedTrait
19
{
20
    /**
21
     * @Gedmo\Translatable
22
     * @ORM\Column(type="string", length=255, nullable=true)
23
     */
24
    protected $excrept;
25
26
    /**
27
     * @Gedmo\Translatable
28
     * @ORM\Column(type="string", length=50, nullable=true)
29
     */
30
    protected $metaRobots;
31
32
    /**
33
     * @ORM\ManyToOne(targetEntity="PiedWeb\CMSBundle\Entity\PageInterface", inversedBy="childrenPages")
34
     */
35
    protected $parentPage;
36
37
    /**
38
     * @ORM\OneToMany(targetEntity="PiedWeb\CMSBundle\Entity\PageInterface", mappedBy="parentPage")
39
     */
40
    protected $childrenPages;
41
42
    /**
43
     * @Gedmo\Translatable
44
     * @ORM\Column(type="string", length=255, nullable=true)
45
     */
46
    protected $h1;
47
48
    /**
49
     * @Gedmo\Translatable
50
     * @ORM\Column(type="string", length=150, nullable=true)
51
     */
52
    protected $name;
53
54
    /**
55
     * @ORM\ManyToOne(targetEntity="PiedWeb\CMSBundle\Entity\UserInterface")
56
     */
57
    protected $author;
58
59
    /**
60
     * @ORM\ManyToMany(targetEntity="PiedWeb\CMSBundle\Entity\PageInterface")
61
     */
62
    protected $relatedPages;
63
64
    /**
65
     * @ORM\Column(type="string", length=250, nullable=true)
66
     */
67
    protected $template;
68
69
    public function __constructExtended()
70
    {
71
        $this->relatedPages = new ArrayCollection();
72
    }
73
74
    public function getExcrept(): ?string
75
    {
76
        return $this->excrept;
77
    }
78
79
    public function setExcrept(?string $excrept): self
80
    {
81
        $this->excrept = $excrept;
82
83
        return $this;
84
    }
85
86
    public function getMetaRobots(): ?string
87
    {
88
        return $this->metaRobots;
89
    }
90
91
    public function setMetaRobots(?string $metaRobots): self
92
    {
93
        $this->metaRobots = $metaRobots;
94
95
        return $this;
96
    }
97
98
    public function getParentPage(): ?self
99
    {
100
        return $this->parentPage;
101
    }
102
103
    public function setParentPage(?self $parentPage): self
104
    {
105
        $this->parentPage = $parentPage;
106
107
        return $this;
108
    }
109
110
    public function getChildrenPages()
111
    {
112
        return $this->childrenPages;
113
    }
114
115
    public function getH1(): ?string
116
    {
117
        return $this->h1;
118
    }
119
120
    public function setH1(?string $h1): self
121
    {
122
        $this->h1 = $h1;
123
124
        return $this;
125
    }
126
127
    public function getName(): ?string
128
    {
129
        return $this->name;
130
    }
131
132
    public function setName(?string $name): self
133
    {
134
        $this->name = $name;
135
136
        return $this;
137
    }
138
139
    public function getAuthor(): ?User
140
    {
141
        return $this->author;
142
    }
143
144
    public function setAuthor(?User $author): self
145
    {
146
        $this->author = $author;
147
148
        return $this;
149
    }
150
151
    /**
152
     * @return Collection|Page[]
153
     */
154
    public function getRelatedPages(): Collection
155
    {
156
        return $this->relatedPages;
157
    }
158
159
    public function addRelatedPage(PageInterface $relatedPage): self
160
    {
161
        if (!$this->relatedPages->contains($relatedPage)) {
162
            $this->relatedPages[] = $relatedPage;
163
        }
164
165
        return $this;
166
    }
167
168
    public function removeRelatedPage(PageInterface $relatedPage): self
169
    {
170
        if ($this->relatedPages->contains($relatedPage)) {
171
            $this->relatedPages->removeElement($relatedPage);
172
        }
173
174
        return $this;
175
    }
176
177
    public function getTemplate(): ?string
178
    {
179
        return $this->template;
180
    }
181
182
    public function setTemplate(?string $template): self
183
    {
184
        $this->template = $template;
185
186
        return $this;
187
    }
188
}
189