|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Victoire\Bundle\BusinessPageBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
use Victoire\Bundle\PageBundle\Entity\PageStatus; |
|
7
|
|
|
use Victoire\Bundle\QueryBundle\Entity\QueryTrait; |
|
8
|
|
|
use Victoire\Bundle\QueryBundle\Entity\VictoireQueryInterface; |
|
9
|
|
|
use Victoire\Bundle\SeoBundle\Entity\PageSeo; |
|
10
|
|
|
use Victoire\Bundle\TemplateBundle\Entity\Template; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* BusinessTemplate. |
|
14
|
|
|
* |
|
15
|
|
|
* @ORM\Entity(repositoryClass="Victoire\Bundle\BusinessPageBundle\Repository\BusinessTemplateRepository") |
|
16
|
|
|
* @ORM\HasLifecycleCallbacks() |
|
17
|
|
|
*/ |
|
18
|
|
|
class BusinessTemplate extends Template implements VictoireQueryInterface |
|
19
|
|
|
{ |
|
20
|
|
|
//This trait add the query and business_entity_id columns |
|
21
|
|
|
use QueryTrait; |
|
22
|
|
|
|
|
23
|
|
|
const TYPE = 'business_template'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @ORM\OneToOne(targetEntity="\Victoire\Bundle\SeoBundle\Entity\PageSeo", cascade={"persist", "remove"}) |
|
27
|
|
|
* @ORM\JoinColumn(name="seo_id", referencedColumnName="id", onDelete="SET NULL") |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $seo; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @ORM\OneToMany(targetEntity="\Victoire\Bundle\BusinessPageBundle\Entity\BusinessPage", mappedBy="template", cascade={"remove"}) |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $inheritors; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var bool |
|
38
|
|
|
* |
|
39
|
|
|
* @deprecated author restriction is handled by the "BUSINESS_ENTITY_OWNER" role since 1.7.7 and will be removed in the 1.8 |
|
40
|
|
|
* |
|
41
|
|
|
* @ORM\Column(name="author_restricted", type="boolean") |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $authorRestricted; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var string |
|
47
|
|
|
* |
|
48
|
|
|
* @ORM\Column(name="backendName", type="string", length=255) |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $backendName; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* contruct. |
|
54
|
|
|
**/ |
|
55
|
|
|
public function __construct() |
|
56
|
|
|
{ |
|
57
|
|
|
parent::__construct(); |
|
58
|
|
|
$this->publishedAt = new \DateTime(); |
|
|
|
|
|
|
59
|
|
|
$this->status = PageStatus::PUBLISHED; |
|
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @return [BusinessPage] |
|
|
|
|
|
|
64
|
|
|
*/ |
|
65
|
|
|
public function getInstances() |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->inheritors; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function setInstances($inheritors) |
|
|
|
|
|
|
71
|
|
|
{ |
|
72
|
|
|
$this->inheritors = $inheritors; |
|
73
|
|
|
|
|
74
|
|
|
return $this; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @return string |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getLayout() |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->layout ? $this->layout : $this->getTemplate()->getLayout(); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Set seo. |
|
87
|
|
|
* |
|
88
|
|
|
* @param PageSeo $seo |
|
89
|
|
|
* |
|
90
|
|
|
* @return BusinessTemplate |
|
91
|
|
|
*/ |
|
92
|
|
|
public function setSeo(PageSeo $seo) |
|
93
|
|
|
{ |
|
94
|
|
|
$this->seo = $seo; |
|
95
|
|
|
|
|
96
|
|
|
return $this; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Get seo. |
|
101
|
|
|
* |
|
102
|
|
|
* @return PageSeo |
|
103
|
|
|
*/ |
|
104
|
|
|
public function getSeo() |
|
105
|
|
|
{ |
|
106
|
|
|
return $this->seo; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @return bool |
|
111
|
|
|
*/ |
|
112
|
|
|
public function isAuthorRestricted() |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->authorRestricted; |
|
|
|
|
|
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @param bool $authorRestricted |
|
119
|
|
|
*/ |
|
120
|
|
|
public function setAuthorRestricted($authorRestricted) |
|
121
|
|
|
{ |
|
122
|
|
|
$this->authorRestricted = $authorRestricted; |
|
|
|
|
|
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @return string |
|
127
|
|
|
*/ |
|
128
|
|
|
public function getBackendName() |
|
129
|
|
|
{ |
|
130
|
|
|
return $this->backendName; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @param string $backendName |
|
135
|
|
|
* |
|
136
|
|
|
* @return $this |
|
137
|
|
|
*/ |
|
138
|
|
|
public function setBackendName($backendName) |
|
139
|
|
|
{ |
|
140
|
|
|
$this->backendName = $backendName; |
|
141
|
|
|
|
|
142
|
|
|
return $this; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* Get inheritors (all Templates having this object as Template). |
|
147
|
|
|
* |
|
148
|
|
|
* @return [Template] |
|
|
|
|
|
|
149
|
|
|
*/ |
|
150
|
|
View Code Duplication |
public function getTemplateInheritors() |
|
|
|
|
|
|
151
|
|
|
{ |
|
152
|
|
|
$templateInheritors = []; |
|
153
|
|
|
foreach ($this->inheritors as $inheritor) { |
|
154
|
|
|
if ($inheritor instanceof self) { |
|
155
|
|
|
$templateInheritors[] = $inheritor; |
|
156
|
|
|
} |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
return $templateInheritors; |
|
160
|
|
|
} |
|
161
|
|
|
} |
|
162
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: