@@ -14,6 +14,11 @@ abstract class AbstractContent
1414
1515 private ?string $ content = null ;
1616
17+ /**
18+ * @var int[]
19+ */
20+ private array $ ancestors = [];
21+
1722 private int $ version = 1 ;
1823 /**
1924 * @var array<string, string> $children
@@ -176,6 +181,7 @@ public function createComment(string $comment): ContentComment
176181 $ contentComment ->setContainerId ($ this ->getId ());
177182 $ contentComment ->setContainerType ($ this ->getType ());
178183 $ contentComment ->setContent ($ comment );
184+ $ contentComment ->setSpace ($ this ->getSpace ());
179185 return $ contentComment ;
180186 }
181187
@@ -187,10 +193,10 @@ public function createComment(string $comment): ContentComment
187193 public function createSubpage (string $ title , string $ body ): ContentPage
188194 {
189195 $ contentPage = new ContentPage ();
190- $ contentPage ->setContainerId ($ this ->getId ());
191- $ contentPage ->setContainerType ($ this ->getType ());
196+ $ contentPage ->addAncestor ($ this ->id );
192197 $ contentPage ->setContent ($ body );
193198 $ contentPage ->setTitle ($ title );
199+ $ contentPage ->setSpace ($ this ->getSpace ());
194200 return $ contentPage ;
195201 }
196202
@@ -226,4 +232,32 @@ public function setContainerType(string $containerType): void
226232 $ this ->containerType = $ containerType ;
227233 }
228234
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