diff options
Diffstat (limited to 'src/model/entities/Presentation.php')
| -rw-r--r-- | src/model/entities/Presentation.php | 22 |
1 files changed, 19 insertions, 3 deletions
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); | |||
| 5 | 5 | ||
| 6 | namespace App\Entity; | 6 | namespace App\Entity; |
| 7 | 7 | ||
| 8 | use Doctrine\ORM\EntityManager; | ||
| 8 | use Doctrine\ORM\Mapping as ORM; | 9 | use Doctrine\ORM\Mapping as ORM; |
| 9 | 10 | ||
| 10 | #[ORM\Entity] | 11 | #[ORM\Entity] |
| 11 | #[ORM\Table(name: TABLE_PREFIX . "presentation")] | 12 | #[ORM\Table(name: TABLE_PREFIX . "presentation")] |
| 12 | class Presentation | 13 | class Presentation |
| 13 | { | 14 | { |
| 15 | static public array $option_list = ['fullwidth' => 'Pleine largeur', 'grid' => 'Grille', 'mosaic' => 'Mosaïque', 'carousel' => 'Carrousel']; | ||
| 16 | |||
| 14 | #[ORM\Id] | 17 | #[ORM\Id] |
| 15 | #[ORM\GeneratedValue] | 18 | #[ORM\GeneratedValue] |
| 16 | #[ORM\Column(type: "integer")] | 19 | #[ORM\Column(type: "integer")] |
| 17 | private int $id_presentation; | 20 | private int $id_presentation; |
| 18 | 21 | ||
| 19 | #[ORM\Column(type: "string", length: 255)] | 22 | #[ORM\Column(type: "string", length: 255)] |
| 20 | private string $name_presentation; | 23 | private string $name; |
| 21 | 24 | ||
| 22 | public function __construct(string $name) | 25 | public function __construct(string $name) |
| 23 | { | 26 | { |
| 24 | $this->name_presentation = $name; | 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 | } | ||
| 25 | } | 33 | } |
| 26 | 34 | ||
| 27 | public function getName(): string | 35 | public function getName(): string |
| 28 | { | 36 | { |
| 29 | return $this->name_presentation; | 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(); | ||
| 30 | } | 46 | } |
| 31 | } \ No newline at end of file | 47 | } \ No newline at end of file |
