Răsfoiți Sursa

avancement modif views

François Drouhard 9 luni în urmă
părinte
comite
692a7efbc2
3 a modificat fișierele cu 21 adăugiri și 8 ștergeri
  1. 9 0
      src/Config/View.php
  2. 9 7
      src/Entity/Profile.php
  3. 3 1
      src/Service/OptionsManager.php

+ 9 - 0
src/Config/View.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace App\Config;
+
+enum View {
+    case TABLEAU;
+    case VIGNETTE;
+}
+

+ 9 - 7
src/Entity/Profile.php

@@ -2,18 +2,20 @@
 
 namespace App\Entity;
 
+use App\Config\View;
 use App\Repository\ProfileRepository;
+use Doctrine\DBAL\Types\Types;
 use Doctrine\ORM\Mapping as ORM;
 
 #[ORM\Entity(repositoryClass: ProfileRepository::class)]
 class Profile
 {
-    public static $VIEW = ['liste' => 0, 'vignette' => 1];
+    //public static $VIEW = ['liste' => 0, 'vignette' => 1];
 
 
     #[ORM\Id]
     #[ORM\GeneratedValue]
-    #[ORM\Column(type: "integer")]
+    #[ORM\Column(type: Types::INTEGER)]
 
     private ?int $id = null;
 
@@ -24,13 +26,13 @@ class Profile
     private ?User $user = null;
 
 
-    #[ORM\Column(type: "integer")]
+    #[ORM\Column(type: Types::INTEGER)]
 
-    private ?int $view = null;
+    private ?View $view = null;
 
     public function __construct()
     {
-        $this->setView(Profile::$VIEW['vignette']);
+        $this->setView(View::VIGNETTE);
     }
 
     public function getId(): ?int
@@ -50,12 +52,12 @@ class Profile
         return $this;
     }
 
-    public function getView(): ?int
+    public function getView(): ?View
     {
         return $this->view;
     }
 
-    public function setView(?int $view): self
+    public function setView(?View $view): self
     {
         $this->view = $view;
 

+ 3 - 1
src/Service/OptionsManager.php

@@ -2,6 +2,7 @@
 
 namespace App\Service;
 
+use App\Config\View;
 use App\Entity\User;
 use App\Entity\Profile;
 use Symfony\Bundle\SecurityBundle\Security;
@@ -23,7 +24,8 @@ class OptionsManager
 
     public function vue(): string
     {
-        if ($this->options->getView() === 0)
+        dump(View::TABLEAU);
+        if ($this->options->getView() === View::TABLEAU)
         {
             return "tableaux";
         } else {