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/entities/Presentation.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/model/entities/Presentation.php') 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