aboutsummaryrefslogtreecommitdiff
path: root/src/model/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/entities')
-rw-r--r--src/model/entities/Log.php7
-rw-r--r--src/model/entities/NodeData.php13
-rw-r--r--src/model/entities/Presentation.php47
3 files changed, 9 insertions, 58 deletions
diff --git a/src/model/entities/Log.php b/src/model/entities/Log.php
index 39b4307..eeb76e4 100644
--- a/src/model/entities/Log.php
+++ b/src/model/entities/Log.php
@@ -16,15 +16,14 @@ class Log
16 #[ORM\Column(type: "integer")] 16 #[ORM\Column(type: "integer")]
17 private int $id_log; 17 private int $id_log;
18 18
19 #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] 19 #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] // CURRENT_TIMESTAMP "inutile", date générée par PHP
20 //#[ORM\Column(type: 'datetime', columnDefinition: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")] 20 private \DateTime $date_time; // type datetime de doctrine <=> type \DateTime de PHP
21 private ?\DateTime $date_time ; // le type datetime de doctrine convertit en type \DateTime de PHP
22 21
23 #[ORM\Column(type: "boolean")] 22 #[ORM\Column(type: "boolean")]
24 private bool $success; 23 private bool $success;
25 24
26 public function __construct(bool $success){ 25 public function __construct(bool $success){
27 $this->date_time = new \DateTime(); 26 $this->date_time = new \DateTime;
28 $this->success = $success; 27 $this->success = $success;
29 } 28 }
30} 29}
diff --git a/src/model/entities/NodeData.php b/src/model/entities/NodeData.php
index 3688e4a..99dda83 100644
--- a/src/model/entities/NodeData.php
+++ b/src/model/entities/NodeData.php
@@ -27,9 +27,8 @@ class NodeData
27 #[ORM\Column(type: "json")] 27 #[ORM\Column(type: "json")]
28 private array $data; 28 private array $data;
29 29
30 #[ORM\ManyToOne(targetEntity: Presentation::class)] 30 #[ORM\Column(type: "string", length: 255, nullable: true)]
31 #[ORM\JoinColumn(name: "presentation_id", referencedColumnName: "id_presentation", nullable: true)] 31 private ?string $presentation;
32 private ?Presentation $presentation;
33 32
34 #[ORM\Column(type: "integer", length: 255, nullable: true)] 33 #[ORM\Column(type: "integer", length: 255, nullable: true)]
35 private ?int $grid_cols_min_width = null; // pour le mode grille 34 private ?int $grid_cols_min_width = null; // pour le mode grille
@@ -43,12 +42,12 @@ class NodeData
43 )] 42 )]
44 private Collection $images; 43 private Collection $images;
45 44
46 public function __construct(array $data, Node $node, Collection $images = new ArrayCollection, Presentation $presentation = null) 45 public function __construct(array $data, Node $node, Collection $images = new ArrayCollection, string $presentation = null)
47 { 46 {
48 $this->data = $data; 47 $this->data = $data;
49 $this->node = $node; 48 $this->node = $node;
50 $this->images = $images; 49 $this->images = $images;
51 if(!empty($presentation) && $presentation->getName() === 'grid'){ 50 if(!empty($presentation) && $presentation === 'grid'){
52 $this->grid_cols_min_width = 250; 51 $this->grid_cols_min_width = 250;
53 } 52 }
54 } 53 }
@@ -75,11 +74,11 @@ class NodeData
75 unset($this->data[$key]); 74 unset($this->data[$key]);
76 } 75 }
77 } 76 }
78 public function getPresentation(): ?Presentation 77 public function getPresentation(): ?string
79 { 78 {
80 return $this->presentation; 79 return $this->presentation;
81 } 80 }
82 public function setPresentation(Presentation $presentation): void 81 public function setPresentation(string $presentation): void
83 { 82 {
84 $this->presentation = $presentation; 83 $this->presentation = $presentation;
85 } 84 }
diff --git a/src/model/entities/Presentation.php b/src/model/entities/Presentation.php
deleted file mode 100644
index 6ada565..0000000
--- a/src/model/entities/Presentation.php
+++ /dev/null
@@ -1,47 +0,0 @@
1<?php
2// src/model/entities/Presentation.php
3
4declare(strict_types=1);
5
6namespace App\Entity;
7
8use Doctrine\ORM\EntityManager;
9use Doctrine\ORM\Mapping as ORM;
10
11#[ORM\Entity]
12#[ORM\Table(name: TABLE_PREFIX . "presentation")]
13class Presentation
14{
15 static public array $option_list = ['fullwidth' => 'Pleine largeur', 'grid' => 'Grille', 'mosaic' => 'Mosaïque', 'carousel' => 'Carrousel'];
16
17 #[ORM\Id]
18 #[ORM\GeneratedValue]
19 #[ORM\Column(type: "integer")]
20 private int $id_presentation;
21
22 #[ORM\Column(type: "string", length: 255)]
23 private string $name;
24
25 public function __construct(string $name)
26 {
27 $this->name = array_keys(self::$option_list)[0]; // = fullwidth, sécurité option inconnue
28 foreach(self::$option_list as $key => $value){
29 if($name === $key){
30 $this->name = $name;
31 }
32 }
33 }
34
35 public function getName(): string
36 {
37 return $this->name;
38 }
39
40 static public function findPresentation(EntityManager $entityManager, string $name): ?self
41 {
42 return $entityManager
43 ->createQuery('SELECT p FROM App\Entity\Presentation p WHERE p.name = :name')
44 ->setParameter('name', $name)
45 ->getOneOrNullResult();
46 }
47} \ No newline at end of file