aboutsummaryrefslogtreecommitdiff
path: root/src/model/entities/NodeData.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/entities/NodeData.php')
-rw-r--r--src/model/entities/NodeData.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/model/entities/NodeData.php b/src/model/entities/NodeData.php
new file mode 100644
index 0000000..ddf6083
--- /dev/null
+++ b/src/model/entities/NodeData.php
@@ -0,0 +1,62 @@
1<?php
2// src/model/entities/NodeData.php
3
4declare(strict_types=1);
5
6namespace App\Entity;
7
8use Doctrine\ORM\Mapping as ORM;
9use Doctrine\Common\Collections\ArrayCollection; // classe
10use Doctrine\Common\Collections\Collection; // interface
11
12#[ORM\Entity]
13#[ORM\Table(name: TABLE_PREFIX . "node_data")]
14class NodeData
15{
16 #[ORM\Id]
17 #[ORM\GeneratedValue]
18 #[ORM\Column(type: "integer")]
19 private int $id_node_data;
20
21 // onDelete: "CASCADE" supprime les données si le noeud est supprimé
22 // inverseBy fait le lien avec $node_data dans Node (qui a "mappedBy")
23 #[ORM\OneToOne(targetEntity: Node::class, inversedBy: "node_data")]
24 #[ORM\JoinColumn(name: "node_id", referencedColumnName: "id_node", onDelete: "CASCADE")]
25 private Node $node;
26
27 #[ORM\Column(type: "json")]
28 private array $data;
29
30 // liaison avec table intermédiaire
31 #[ORM\ManyToMany(targetEntity: Image::class, inversedBy: "id_image")]
32 #[ORM\JoinTable(
33 name: "nb_node_image",
34 joinColumns: [new ORM\JoinColumn(name: "node_data_id", referencedColumnName: "id_node_data", onDelete: "CASCADE")],
35 inverseJoinColumns: [new ORM\JoinColumn(name: "image_id", referencedColumnName: "id_image", onDelete: "CASCADE")]
36 )]
37 private Collection $images;
38
39 public function __construct(array $data, Node $node, Collection $images = new ArrayCollection)
40 {
41 $this->data = $data;
42 $this->node = $node;
43 $this->images = $images;
44 }
45
46 public function getData(): array
47 {
48 return $this->data;
49 }
50 /*public function setData(array $data): void
51 {
52 $this->data = $data;
53 }
54 public function setNode(Node $node): void
55 {
56 $this->node = $node;
57 }*/
58 public function getImages(): Collection
59 {
60 return $this->images;
61 }
62}