1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App\Document; |
15
|
|
|
|
16
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
17
|
|
|
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; |
18
|
|
|
use PHPCR\NodeInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @PHPCRODM\Document(referenceable=true) |
22
|
|
|
*/ |
23
|
|
|
class Content |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @PHPCRODM\Id |
27
|
|
|
*/ |
28
|
|
|
protected $id; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @PHPCRODM\Node |
32
|
|
|
*/ |
33
|
|
|
protected $node; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @PHPCRODM\ParentDocument |
37
|
|
|
*/ |
38
|
|
|
protected $parentDocument; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @PHPCRODM\Nodename |
42
|
|
|
*/ |
43
|
|
|
protected $name; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @PHPCRODM\Field(type="string") |
47
|
|
|
*/ |
48
|
|
|
protected $title; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @PHPCRODM\Child() |
52
|
|
|
* |
53
|
|
|
* @var Content |
54
|
|
|
*/ |
55
|
|
|
protected $child; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @PHPCRODM\Children() |
59
|
|
|
* |
60
|
|
|
* @var ArrayCollection|Content[] |
61
|
|
|
*/ |
62
|
|
|
protected $children; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @PHPCRODM\ReferenceOne(targetDocument="Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App\Document\Content") |
66
|
|
|
* |
67
|
|
|
* @var Content |
68
|
|
|
*/ |
69
|
|
|
protected $singleRoute; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @PHPCRODM\ReferenceMany(targetDocument="Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App\Document\Content") |
73
|
|
|
* |
74
|
|
|
* @var ArrayCollection|Content[] |
75
|
|
|
*/ |
76
|
|
|
protected $routes; |
77
|
|
|
|
78
|
|
|
public function __construct() |
79
|
|
|
{ |
80
|
|
|
$this->children = new ArrayCollection(); |
81
|
|
|
$this->routes = new ArrayCollection(); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return mixed |
86
|
|
|
*/ |
87
|
|
|
public function getId() |
88
|
|
|
{ |
89
|
|
|
return $this->id; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Gets the underlying PHPCR node of this content. |
94
|
|
|
* |
95
|
|
|
* @return NodeInterface |
96
|
|
|
*/ |
97
|
|
|
public function getNode() |
98
|
|
|
{ |
99
|
|
|
return $this->node; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Sets the parent document. |
104
|
|
|
* |
105
|
|
|
* @param object $parent the parent document |
106
|
|
|
*/ |
107
|
|
|
public function setParentDocument($parent) |
108
|
|
|
{ |
109
|
|
|
$this->parentDocument = $parent; |
110
|
|
|
|
111
|
|
|
return $this; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Gets the parent document. |
116
|
|
|
* |
117
|
|
|
* @return object |
118
|
|
|
*/ |
119
|
|
|
public function getParentDocument() |
120
|
|
|
{ |
121
|
|
|
return $this->parentDocument; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Sets the document name. |
126
|
|
|
* |
127
|
|
|
* @param string $name |
128
|
|
|
*/ |
129
|
|
|
public function setName($name) |
130
|
|
|
{ |
131
|
|
|
$this->name = $name; |
132
|
|
|
|
133
|
|
|
return $this; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Gets the document name. |
138
|
|
|
* |
139
|
|
|
* @return string |
140
|
|
|
*/ |
141
|
|
|
public function getName() |
142
|
|
|
{ |
143
|
|
|
return $this->name; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @return string |
148
|
|
|
*/ |
149
|
|
|
public function getTitle() |
150
|
|
|
{ |
151
|
|
|
return $this->title; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @param string $title |
156
|
|
|
*/ |
157
|
|
|
public function setTitle($title) |
158
|
|
|
{ |
159
|
|
|
$this->title = $title; |
160
|
|
|
|
161
|
|
|
return $this; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @return string |
166
|
|
|
*/ |
167
|
|
|
public function getBody() |
168
|
|
|
{ |
169
|
|
|
return $this->body; |
|
|
|
|
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @param string $body |
174
|
|
|
* |
175
|
|
|
* @return Content |
176
|
|
|
*/ |
177
|
|
|
public function setBody($body) |
178
|
|
|
{ |
179
|
|
|
$this->body = $body; |
180
|
|
|
|
181
|
|
|
return $this; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @return Content |
186
|
|
|
*/ |
187
|
|
|
public function getChild() |
188
|
|
|
{ |
189
|
|
|
return $this->child; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @param mixed $child |
194
|
|
|
*/ |
195
|
|
|
public function setChild($child) |
196
|
|
|
{ |
197
|
|
|
$this->child = $child; |
198
|
|
|
|
199
|
|
|
return $this; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* @return mixed |
204
|
|
|
*/ |
205
|
|
|
public function getChildren() |
206
|
|
|
{ |
207
|
|
|
return $this->children; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @param mixed $children |
212
|
|
|
*/ |
213
|
|
|
public function setChildren($children) |
214
|
|
|
{ |
215
|
|
|
$this->children = $children; |
216
|
|
|
|
217
|
|
|
return $this; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @return mixed |
222
|
|
|
*/ |
223
|
|
|
public function getSingleRoute() |
224
|
|
|
{ |
225
|
|
|
return $this->singleRoute; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param mixed $singleRoute |
230
|
|
|
*/ |
231
|
|
|
public function setSingleRoute($singleRoute) |
232
|
|
|
{ |
233
|
|
|
$this->singleRoute = $singleRoute; |
234
|
|
|
|
235
|
|
|
return $this; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @return ArrayCollection|Content[] |
240
|
|
|
*/ |
241
|
|
|
public function getRoutes() |
242
|
|
|
{ |
243
|
|
|
return $this->routes; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* @param ArrayCollection|Content[] $routes |
248
|
|
|
*/ |
249
|
|
|
public function setRoutes($routes) |
250
|
|
|
{ |
251
|
|
|
$this->routes = $routes; |
252
|
|
|
|
253
|
|
|
return $this; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* @param $route |
258
|
|
|
*/ |
259
|
|
|
public function addRoute($route): void |
260
|
|
|
{ |
261
|
|
|
$this->routes->add($route); |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* @param $route |
266
|
|
|
*/ |
267
|
|
|
public function removeRoute($route): void |
268
|
|
|
{ |
269
|
|
|
$this->routes->removeElement($route); |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* @param $child |
274
|
|
|
*/ |
275
|
|
|
public function addChild($child): void |
276
|
|
|
{ |
277
|
|
|
$this->children->add($child); |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* @param $child |
282
|
|
|
*/ |
283
|
|
|
public function removeChild($child): void |
284
|
|
|
{ |
285
|
|
|
$this->children->removeElement($child); |
286
|
|
|
} |
287
|
|
|
} |
288
|
|
|
|
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: