@@ -14,6 +14,11 @@ abstract class AbstractContent
14
14
15
15
private ?string $ content = null ;
16
16
17
+ /**
18
+ * @var int[]
19
+ */
20
+ private array $ ancestors = [];
21
+
17
22
private int $ version = 1 ;
18
23
/**
19
24
* @var array<string, string> $children
@@ -176,6 +181,7 @@ public function createComment(string $comment): ContentComment
176
181
$ contentComment ->setContainerId ($ this ->getId ());
177
182
$ contentComment ->setContainerType ($ this ->getType ());
178
183
$ contentComment ->setContent ($ comment );
184
+ $ contentComment ->setSpace ($ this ->getSpace ());
179
185
return $ contentComment ;
180
186
}
181
187
@@ -187,10 +193,10 @@ public function createComment(string $comment): ContentComment
187
193
public function createSubpage (string $ title , string $ body ): ContentPage
188
194
{
189
195
$ contentPage = new ContentPage ();
190
- $ contentPage ->setContainerId ($ this ->getId ());
191
- $ contentPage ->setContainerType ($ this ->getType ());
196
+ $ contentPage ->addAncestor ($ this ->id );
192
197
$ contentPage ->setContent ($ body );
193
198
$ contentPage ->setTitle ($ title );
199
+ $ contentPage ->setSpace ($ this ->getSpace ());
194
200
return $ contentPage ;
195
201
}
196
202
@@ -226,4 +232,32 @@ public function setContainerType(string $containerType): void
226
232
$ this ->containerType = $ containerType ;
227
233
}
228
234
229
- }
235
+ /**
236
+ * @return int[]
237
+ */
238
+ public function getAncestors (): array
239
+ {
240
+ return $ this ->ancestors ;
241
+ }
242
+
243
+ /**
244
+ * @param int[] $ancestors
245
+ * @return self
246
+ */
247
+ public function setAncestors (array $ ancestors ): self
248
+ {
249
+ $ this ->ancestors = $ ancestors ;
250
+ return $ this ;
251
+ }
252
+
253
+ /**
254
+ * @param int $id
255
+ * @return self
256
+ */
257
+ public function addAncestor (int $ id ): self
258
+ {
259
+ $ this ->ancestors [] = $ id ;
260
+ return $ this ;
261
+ }
262
+
263
+ }
0 commit comments