name_node = $name; $this->article_timestamp = $article_timestamp; $this->attributes = $attributes; $this->position = $position; $this->parent = $parent; $this->page = $page; $this->article = $article; } public function addChild(self $child): void { $this->children[] = $child; $this->sortChildren(); } // utiliser $position pour afficher les éléments dans l'ordre private function sortChildren(): void { $iteration = count($this->children); while($iteration > 1) { for($i = 0; $i < $iteration - 1; $i++) { //echo '
' . $this->children[$i]->getPosition() . ' - ' . $this->children[$i + 1]->getPosition(); if($this->children[$i]->getPosition() > $this->children[$i + 1]->getPosition()) { $tmp = $this->children[$i]; $this->children[$i] = $this->children[$i + 1]; $this->children[$i + 1] = $tmp; } } $iteration--; } } // pfff... public function getId(): int { return $this->id_node; } public function getName(): string { return $this->name_node; } /*public function setName(string $name): void { $this->name_node = $name; }*/ public function getArticleTimestamp(): string { return $this->article_timestamp; } public function getAttributes(): array { return $this->attributes; } /*public function setAttributes(array $attributes): void { $this->attributes = $attributes; }*/ public function getParent(): ?self { return $this->parent; } /*public function setParent(?self $parent): void { $this->parent = $parent; }*/ public function getPosition(): int { return $this->position; } public function setPosition(int $position): void { $this->position = $position; } public function getPage(): Page { return $this->page; } /*public function setPage(Page $page): void { $this->page = $page; }*/ public function getArticle(): Article { return $this->article; } /*public function setArticle(Article $article): void { $this->article = $article; }*/ public function getNodeData(): ?NodeData { return $this->node_data; } public function getChildren(): array { return $this->children; } public function getTempChild(): ?self // peut renvoyer null { return $this->temp_child; } public function setTempChild(self $child): void { $this->temp_child = $child; } }