From f477314613beb26b0ce4c61ec0b1900df1de1cb1 Mon Sep 17 00:00:00 2001 From: polo Date: Mon, 1 Sep 2025 18:52:17 +0200 Subject: =?UTF-8?q?renommage=20des=20pr=C3=A9sentations,modif=20pr=C3=A9se?= =?UTF-8?q?ntation=20des=20blocs=20et=20largeur=20min=20(donc=20nb=20de=20?= =?UTF-8?q?colonnes)=20en=20mode=20grid,=20corrections=20de=20bugs=20et=20?= =?UTF-8?q?erreurs=20404,=20le=20param=20page=5Fmodif=20n'est=20plus=20une?= =?UTF-8?q?=20action,=20l=C3=A9g=C3=A8re=20symfonyfication=20du=20routeur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/Blocks.php | 4 ++-- src/model/entities/Node.php | 9 +++++++++ src/model/entities/NodeData.php | 40 ++++++++++++++++++++++++++----------- src/model/entities/Presentation.php | 22 +++++++++++++++++--- 4 files changed, 58 insertions(+), 17 deletions(-) (limited to 'src/model') diff --git a/src/model/Blocks.php b/src/model/Blocks.php index f6475cd..a6fab45 100644 --- a/src/model/Blocks.php +++ b/src/model/Blocks.php @@ -3,10 +3,10 @@ class Blocks{ /*private array $types = ['blog', 'grid', 'calendar', 'galery', 'form'];*/ - static private array $types = ['post_block', 'news_block', 'calendar', 'galery', 'form']; + static private array $types = ['post_block', 'news_block', 'galery', 'calendar', 'form']; /*private array $names = ['Blog', 'Grille', 'Calendrier', 'Galerie', 'Formulaire'];*/ - static private array $names = ['Articles libres', 'Actualités', 'Calendrier', 'Galerie', 'Formulaire']; + static private array $names = ['Articles libres', 'Actualités', 'Galerie', 'Calendrier', 'Formulaire']; static public function getNameList(): array { diff --git a/src/model/entities/Node.php b/src/model/entities/Node.php index 93363d3..7cf395c 100644 --- a/src/model/entities/Node.php +++ b/src/model/entities/Node.php @@ -161,6 +161,15 @@ class Node { return $this->children; } + public function getNodeByName(string $name): ?Node + { + foreach($this->children as $child){ + if($child->getName() === $name){ + return $child; + } + } + return null; + } public function addChild(self $child): void { $this->children[] = $child; diff --git a/src/model/entities/NodeData.php b/src/model/entities/NodeData.php index c835727..3688e4a 100644 --- a/src/model/entities/NodeData.php +++ b/src/model/entities/NodeData.php @@ -24,12 +24,15 @@ class NodeData #[ORM\JoinColumn(name: "node_id", referencedColumnName: "id_node", onDelete: "CASCADE")] private Node $node; + #[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; + private ?Presentation $presentation; - #[ORM\Column(type: "json")] - private array $data; + #[ORM\Column(type: "integer", length: 255, nullable: true)] + private ?int $grid_cols_min_width = null; // pour le mode grille // liaison avec table intermédiaire #[ORM\ManyToMany(targetEntity: Image::class, inversedBy: "node_data")] @@ -40,25 +43,20 @@ class NodeData )] private Collection $images; - public function __construct(array $data, Node $node, Collection $images = new ArrayCollection) + public function __construct(array $data, Node $node, Collection $images = new ArrayCollection, Presentation $presentation = null) { $this->data = $data; $this->node = $node; $this->images = $images; + if(!empty($presentation) && $presentation->getName() === 'grid'){ + $this->grid_cols_min_width = 250; + } } public function getId(): int { return $this->id_node_data; } - public function getPresentation(): Presentation - { - return $this->presentation; - } - public function setPresentation(Presentation $presentation): void - { - $this->presentation = $presentation; - } public function getData(): array { return $this->data; @@ -77,6 +75,24 @@ class NodeData unset($this->data[$key]); } } + public function getPresentation(): ?Presentation + { + return $this->presentation; + } + public function setPresentation(Presentation $presentation): void + { + $this->presentation = $presentation; + } + public function getColsMinWidth(): int + { + $default = 320; // pixels + return $this->grid_cols_min_width === null ? $default : $this->grid_cols_min_width; + } + public function setColsMinWidth(int $columns): void + { + $this->grid_cols_min_width = $columns; + } + /*public function setNode(Node $node): void { $this->node = $node; diff --git a/src/model/entities/Presentation.php b/src/model/entities/Presentation.php index 73b6a6a..6ada565 100644 --- a/src/model/entities/Presentation.php +++ b/src/model/entities/Presentation.php @@ -5,27 +5,43 @@ declare(strict_types=1); namespace App\Entity; +use Doctrine\ORM\EntityManager; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity] #[ORM\Table(name: TABLE_PREFIX . "presentation")] class Presentation { + static public array $option_list = ['fullwidth' => '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_presentation; + private string $name; public function __construct(string $name) { - $this->name_presentation = $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_presentation; + 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