['body', 'head', 'nav', 'foot'],'js_array' => ['main']]; public function __construct(string $name = '', ?string $article_timestamp = null, array $attributes = [], int $position = 0, ?self $parent = null, ?Page $page = null, ?Article $article = null) { $this->name_node = $name; $this->article_timestamp = $article_timestamp; $this->attributes = $attributes; $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 getArticleTimestamp(): string { return $this->article_timestamp; } 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] = []; } $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 addChild(self $child): void { $this->children[] = $child; $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; } }