From f9a9bf1ae4fac9317fd71f0bcb207544b000e6f1 Mon Sep 17 00:00:00 2001 From: polo Date: Thu, 23 Oct 2025 14:15:01 +0200 Subject: =?UTF-8?q?t=C3=A9l=C3=A9chargement=20d'assets=20dans=20head,=20he?= =?UTF-8?q?ader=20et=20footer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/entities/NodeData.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/model/entities/NodeData.php') diff --git a/src/model/entities/NodeData.php b/src/model/entities/NodeData.php index 5938eca..9db866e 100644 --- a/src/model/entities/NodeData.php +++ b/src/model/entities/NodeData.php @@ -39,11 +39,10 @@ class NodeData #[ORM\Column(type: "integer", nullable: true)] private ?int $pagination_limit = null; // pour les post_block et news_block - // liaison avec table intermédiaire - #[ORM\ManyToMany(targetEntity: Asset::class, inversedBy: "node_data")] + #[ORM\ManyToMany(targetEntity: Asset::class, inversedBy: "node_data")] // cascade: ['remove'] = très dangereux! #[ORM\JoinTable( - name: TABLE_PREFIX . "node_asset", - joinColumns: [new ORM\JoinColumn(name: "node_data_id", referencedColumnName: "id_node_data", onDelete: "CASCADE")], + name: TABLE_PREFIX . "nodedata_asset", + joinColumns: [new ORM\JoinColumn(name: "node_data_id", referencedColumnName: "id_node_data", onDelete: "CASCADE")], // onDelete: "CASCADE": très utile inverseJoinColumns: [new ORM\JoinColumn(name: "asset_id", referencedColumnName: "id_asset", onDelete: "CASCADE")] )] private Collection $assets; @@ -137,8 +136,18 @@ class NodeData { return $this->assets; } - public function setAssets(Collection $assets): void + public function addAsset(Asset $asset): void { - $this->assets = $assets; + if(!$this->assets->contains($asset)){ + $this->assets->add($asset); + //$asset->addNodeData($this); // autre sens + } + } + public function removeAsset(Asset $asset): void + { + $this->assets->removeElement($asset); + /*if($this->assets->removeElement($asset)){ // autre sens + $asset->removeNodeData($this); + }*/ } } -- cgit v1.2.3