From 0fa852ee4e9c3060ba7fc0daf4b08a44ea151f7f Mon Sep 17 00:00:00 2001 From: polo Date: Thu, 2 Jul 2026 00:01:31 +0200 Subject: =?UTF-8?q?entit=C3=A9=20Presentation,=20MAJ=20filtre=20ViewContro?= =?UTF-8?q?ller::SPECIAL=5FPAGES,=20table=20node=5Fdata=20non=20all=C3=A9g?= =?UTF-8?q?=C3=A9e=20pour=20l'instant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/entities/Node.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/model/entities/Node.php') diff --git a/src/model/entities/Node.php b/src/model/entities/Node.php index fb2d867..7932efc 100644 --- a/src/model/entities/Node.php +++ b/src/model/entities/Node.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace App\Entity; -use Config; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity] @@ -48,6 +47,9 @@ class Node #[ORM\OneToOne(targetEntity: EmailForm::class, mappedBy: "node", cascade: ['persist'])] // pas de remove, les e-mails sont associés au EmailForm private ?EmailForm $email_form = null; + #[ORM\OneToOne(targetEntity: Presentation::class, mappedBy: "node", cascade: ['persist', 'remove'])] + private ?Presentation $presentation = null; + // attributs non destinés à doctrine private array $children = []; // tableau de Node private ?self $adopted = null; // = "new" est un enfant de "main" lorsque la page est "article" @@ -111,11 +113,15 @@ class Node // une interface serait cool! // OU possible un "héritage doctrine", faire en sorte que Node soit la mère de NodeData, EmailForm, Article... - // une seulle instance est matérialisée par plusieurs tables en même temps - public function getNodeData(): NodeData|EmailForm|null - { - // limite du polymorphisme avec doctrine => impossible d'avoir une unique variable $node_data - return $this->name_node === 'form' ? $this->email_form : $this->node_data; + // une seule instance est matérialisée par plusieurs tables en même temps + public function getNodeData(): NodeData|EmailForm|Presentation|null + { + // pour du polymorphisme (une unique variable $node_data): opter pour l'héritage + return match($this->name_node){ + 'form' => $this->email_form, + 'post_block', 'news_block' => $this->presentation, + default => $this->node_data, // inclut 'calendar' + }; } public function getChildren(): array { @@ -134,7 +140,7 @@ class Node { $this->children[] = $child; - if(!\Blocks::hasPresentation($this->getName())){ // post_block et news_block ont leurs enfants ordonnés avec ORDER BY + if(!Presentation::hasPresentation($this->getName())){ // post_block et news_block ont leurs enfants ordonnés avec ORDER BY $this->sortChildren(false); } } -- cgit v1.2.3