From e93cd6c352a8e4fbb4e1174bdb15484adbe4c0f7 Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 26 Sep 2025 12:04:02 +0200 Subject: suppression table Presentation --- src/model/entities/Log.php | 7 +++--- src/model/entities/NodeData.php | 13 +++++----- src/model/entities/Presentation.php | 47 ------------------------------------- 3 files changed, 9 insertions(+), 58 deletions(-) delete mode 100644 src/model/entities/Presentation.php (limited to 'src/model/entities') 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 #[ORM\Column(type: "integer")] private int $id_log; - #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] - //#[ORM\Column(type: 'datetime', columnDefinition: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")] - private ?\DateTime $date_time ; // le type datetime de doctrine convertit en type \DateTime de PHP + #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] // CURRENT_TIMESTAMP "inutile", date générée par PHP + private \DateTime $date_time; // type datetime de doctrine <=> type \DateTime de PHP #[ORM\Column(type: "boolean")] private bool $success; public function __construct(bool $success){ - $this->date_time = new \DateTime(); + $this->date_time = new \DateTime; $this->success = $success; } } 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 #[ORM\Column(type: "json")] private array $data; - #[ORM\ManyToOne(targetEntity: Presentation::class)] - #[ORM\JoinColumn(name: "presentation_id", referencedColumnName: "id_presentation", nullable: true)] - private ?Presentation $presentation; + #[ORM\Column(type: "string", length: 255, nullable: true)] + private ?string $presentation; #[ORM\Column(type: "integer", length: 255, nullable: true)] private ?int $grid_cols_min_width = null; // pour le mode grille @@ -43,12 +42,12 @@ class NodeData )] private Collection $images; - public function __construct(array $data, Node $node, Collection $images = new ArrayCollection, Presentation $presentation = null) + public function __construct(array $data, Node $node, Collection $images = new ArrayCollection, string $presentation = null) { $this->data = $data; $this->node = $node; $this->images = $images; - if(!empty($presentation) && $presentation->getName() === 'grid'){ + if(!empty($presentation) && $presentation === 'grid'){ $this->grid_cols_min_width = 250; } } @@ -75,11 +74,11 @@ class NodeData unset($this->data[$key]); } } - public function getPresentation(): ?Presentation + public function getPresentation(): ?string { return $this->presentation; } - public function setPresentation(Presentation $presentation): void + public function setPresentation(string $presentation): void { $this->presentation = $presentation; } 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 @@ - 'Pleine largeur', 'grid' => 'Grille', 'mosaic' => 'Mosaïque', 'carousel' => 'Carrousel']; - - #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column(type: "integer")] - private int $id_presentation; - - #[ORM\Column(type: "string", length: 255)] - private string $name; - - public function __construct(string $name) - { - $this->name = array_keys(self::$option_list)[0]; // = fullwidth, sécurité option inconnue - foreach(self::$option_list as $key => $value){ - if($name === $key){ - $this->name = $name; - } - } - } - - public function getName(): string - { - return $this->name; - } - - static public function findPresentation(EntityManager $entityManager, string $name): ?self - { - return $entityManager - ->createQuery('SELECT p FROM App\Entity\Presentation p WHERE p.name = :name') - ->setParameter('name', $name) - ->getOneOrNullResult(); - } -} \ No newline at end of file -- cgit v1.2.3