diff options
| author | polo <ordipolo@gmx.fr> | 2026-06-11 01:35:57 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2026-06-11 01:35:57 +0200 |
| commit | b76547767ae897b6de752c56e2cef6079ca4abcb (patch) | |
| tree | d76006e86198189c949b36b2c284067b9603e3fc /src/model/entities/EmailForm.php | |
| parent | ae217a6e4b0c29346381e2a410fd7810cb33ce3f (diff) | |
| download | cms-b76547767ae897b6de752c56e2cef6079ca4abcb.tar.gz cms-b76547767ae897b6de752c56e2cef6079ca4abcb.tar.bz2 cms-b76547767ae897b6de752c56e2cef6079ca4abcb.zip | |
classe EmailForm à Email et détachable de Node
Diffstat (limited to 'src/model/entities/EmailForm.php')
| -rw-r--r-- | src/model/entities/EmailForm.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/model/entities/EmailForm.php b/src/model/entities/EmailForm.php new file mode 100644 index 0000000..466a389 --- /dev/null +++ b/src/model/entities/EmailForm.php | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | <?php | ||
| 2 | // src/model/entities/EmailForm.php | ||
| 3 | |||
| 4 | declare(strict_types=1); | ||
| 5 | |||
| 6 | namespace App\Entity; | ||
| 7 | |||
| 8 | use Doctrine\ORM\Mapping as ORM; | ||
| 9 | //use Doctrine\Common\Collections\ArrayCollection; | ||
| 10 | |||
| 11 | #[ORM\Entity] | ||
| 12 | #[ORM\Table(name: TABLE_PREFIX . "email_form")] | ||
| 13 | class EmailForm{ | ||
| 14 | #[ORM\Id] | ||
| 15 | #[ORM\GeneratedValue] | ||
| 16 | #[ORM\Column(type: "integer")] | ||
| 17 | private int $id_email_form; | ||
| 18 | |||
| 19 | // inverseBy fait le lien avec $email_form dans Node (qui a "mappedBy") | ||
| 20 | #[ORM\OneToOne(targetEntity: Node::class, inversedBy: "email_form")] | ||
| 21 | #[ORM\JoinColumn(name: "node_id", referencedColumnName: "id_node")] | ||
| 22 | private ?Node $node; | ||
| 23 | |||
| 24 | #[ORM\Column(type: "json")] | ||
| 25 | private array $data; | ||
| 26 | |||
| 27 | public function __construct(array $data, Node $node){ | ||
| 28 | $this->data = $data; | ||
| 29 | $this->node = $node; | ||
| 30 | } | ||
| 31 | |||
| 32 | public function getId(): int | ||
| 33 | { | ||
| 34 | return $this->id_email_form; | ||
| 35 | } | ||
| 36 | |||
| 37 | // getData et updateData sont indentiques au code dans NodeData | ||
| 38 | // plutôt qu'une interface, pourquoi pas une classe abstraite? ou peut-être un trait? | ||
| 39 | public function getData(): array | ||
| 40 | { | ||
| 41 | return $this->data; | ||
| 42 | } | ||
| 43 | public function updateData(string $key, string|int|bool|array $value = ''): void | ||
| 44 | { | ||
| 45 | if($value !== ''){ | ||
| 46 | $this->data[$key] = $value; | ||
| 47 | } | ||
| 48 | // si $value est vide, supprime la clé | ||
| 49 | elseif(isset($this->data[$key])){ | ||
| 50 | unset($this->data[$key]); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | public function setNode(?Node $node): void | ||
| 55 | { | ||
| 56 | $this->node = $node; | ||
| 57 | } | ||
| 58 | } \ No newline at end of file | ||
