name_node = $name; $this->position = $position; $this->parent = $parent; $this->page = $page; $this->article = $article; } // 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 getAttributes(): array { return $this->attributes; } public function setDefaultAttributes(array $attributes): void { $this->attributes = $attributes; } public function useDefaultAttributes(): void { $this->attributes = self::$default_attributes; } public function addAttribute(string $key, string $value): void { if(!isset($this->attributes[$key])) { // sécurité $key inexistante $this->attributes[$key] = []; } if(!in_array($value, $this->attributes[$key])){ $this->attributes[$key][] = $value; } }*/ /*public function removeAttribute(string $key, string $value): void { if(isset($this->attributes[$key])) // sécurité $key inexistante { // supprime et réindex avec un nouveau tableau $tmp_array = $this->attributes[$key]; $this->attributes[$key] = []; foreach($tmp_array as $entry){ if($entry !== $value){ $this->attributes[$key][] = $entry; } } } }*/ 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 getNodeByName(string $name): ?Node { foreach($this->children as $child){ if($child->getName() === $name){ return $child; } } return null; } public function addChild(self $child): void { $this->children[] = $child; if(!\Blocks::hasPresentation($this->getName())){ // post_block et news_block ont leurs enfants ordonnés avec ORDER BY $this->sortChildren(false); } } public function removeChild(self $child): void { foreach($this->children as $key => $object){ if($object->getId() === $child->getId()){ unset($this->children[$key]); } break; } $this->children = array_values($this->children); // réindexer pour supprimer la case vide } public function getAdoptedChild(): ?self // peut renvoyer null { return $this->adopted; } public function setAdoptedChild(self $child): void { $this->adopted = $child; } }