diff options
author | polo <ordipolo@gmx.fr> | 2025-09-26 12:04:02 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2025-09-26 12:04:02 +0200 |
commit | e93cd6c352a8e4fbb4e1174bdb15484adbe4c0f7 (patch) | |
tree | 7fd1591a25d3557f5869a688bad28db533d6b414 /src/model | |
parent | f977313ff095a10478291334109d9aae40528a34 (diff) | |
download | cms-e93cd6c352a8e4fbb4e1174bdb15484adbe4c0f7.zip |
suppression table Presentation
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/Blocks.php | 37 | ||||
-rw-r--r-- | src/model/entities/Log.php | 7 | ||||
-rw-r--r-- | src/model/entities/NodeData.php | 13 | ||||
-rw-r--r-- | src/model/entities/Presentation.php | 47 |
4 files changed, 12 insertions, 92 deletions
diff --git a/src/model/Blocks.php b/src/model/Blocks.php index a6fab45..53268db 100644 --- a/src/model/Blocks.php +++ b/src/model/Blocks.php | |||
@@ -1,38 +1,7 @@ | |||
1 | <?php | 1 | <?php |
2 | // src/Blocks.php | 2 | // src/model/Blocks.php |
3 | 3 | ||
4 | class Blocks{ | 4 | class Blocks{ |
5 | /*private array $types = ['blog', 'grid', 'calendar', 'galery', 'form'];*/ | 5 | static public array $blocks = ['post_block' => 'Articles libres', 'news_block' => 'Actualités', 'galery' => 'Galerie', 'calendar' => 'Calendrier', 'form' => 'Formulaire']; |
6 | static private array $types = ['post_block', 'news_block', 'galery', 'calendar', 'form']; | 6 | static public array $presentations = ['fullwidth' => 'Pleine largeur', 'grid' => 'Grille', 'mosaic' => 'Mosaïque', 'carousel' => 'Carrousel']; |
7 | |||
8 | /*private array $names = ['Blog', 'Grille', 'Calendrier', 'Galerie', 'Formulaire'];*/ | ||
9 | static private array $names = ['Articles libres', 'Actualités', 'Galerie', 'Calendrier', 'Formulaire']; | ||
10 | |||
11 | static public function getNameList(): array | ||
12 | { | ||
13 | $blocks = []; | ||
14 | foreach(self::$types as $type){ | ||
15 | $blocks[] = $type; | ||
16 | } | ||
17 | return $blocks; | ||
18 | } | ||
19 | |||
20 | static public function getTypeNamePairs(): array | ||
21 | { | ||
22 | $blocks = []; | ||
23 | for($i = 0; $i < count(self::$types); $i++){ | ||
24 | $blocks[] = ['type' => self::$types[$i], 'name' => self::$names[$i]]; | ||
25 | } | ||
26 | return $blocks; | ||
27 | } | ||
28 | |||
29 | static public function getNameFromType(string $type): string | ||
30 | { | ||
31 | for($i=0; $i < count(self::$types); $i++){ | ||
32 | if(self::$types[$i] === $type){ | ||
33 | return self::$names[$i]; | ||
34 | } | ||
35 | } | ||
36 | return 'server side error'; | ||
37 | } | ||
38 | } \ No newline at end of file | 7 | } \ No newline at end of file |
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 | |||
16 | #[ORM\Column(type: "integer")] | 16 | #[ORM\Column(type: "integer")] |
17 | private int $id_log; | 17 | private int $id_log; |
18 | 18 | ||
19 | #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] | 19 | #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] // CURRENT_TIMESTAMP "inutile", date générée par PHP |
20 | //#[ORM\Column(type: 'datetime', columnDefinition: "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")] | 20 | private \DateTime $date_time; // type datetime de doctrine <=> type \DateTime de PHP |
21 | private ?\DateTime $date_time ; // le type datetime de doctrine convertit en type \DateTime de PHP | ||
22 | 21 | ||
23 | #[ORM\Column(type: "boolean")] | 22 | #[ORM\Column(type: "boolean")] |
24 | private bool $success; | 23 | private bool $success; |
25 | 24 | ||
26 | public function __construct(bool $success){ | 25 | public function __construct(bool $success){ |
27 | $this->date_time = new \DateTime(); | 26 | $this->date_time = new \DateTime; |
28 | $this->success = $success; | 27 | $this->success = $success; |
29 | } | 28 | } |
30 | } | 29 | } |
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 | |||
27 | #[ORM\Column(type: "json")] | 27 | #[ORM\Column(type: "json")] |
28 | private array $data; | 28 | private array $data; |
29 | 29 | ||
30 | #[ORM\ManyToOne(targetEntity: Presentation::class)] | 30 | #[ORM\Column(type: "string", length: 255, nullable: true)] |
31 | #[ORM\JoinColumn(name: "presentation_id", referencedColumnName: "id_presentation", nullable: true)] | 31 | private ?string $presentation; |
32 | private ?Presentation $presentation; | ||
33 | 32 | ||
34 | #[ORM\Column(type: "integer", length: 255, nullable: true)] | 33 | #[ORM\Column(type: "integer", length: 255, nullable: true)] |
35 | private ?int $grid_cols_min_width = null; // pour le mode grille | 34 | private ?int $grid_cols_min_width = null; // pour le mode grille |
@@ -43,12 +42,12 @@ class NodeData | |||
43 | )] | 42 | )] |
44 | private Collection $images; | 43 | private Collection $images; |
45 | 44 | ||
46 | public function __construct(array $data, Node $node, Collection $images = new ArrayCollection, Presentation $presentation = null) | 45 | public function __construct(array $data, Node $node, Collection $images = new ArrayCollection, string $presentation = null) |
47 | { | 46 | { |
48 | $this->data = $data; | 47 | $this->data = $data; |
49 | $this->node = $node; | 48 | $this->node = $node; |
50 | $this->images = $images; | 49 | $this->images = $images; |
51 | if(!empty($presentation) && $presentation->getName() === 'grid'){ | 50 | if(!empty($presentation) && $presentation === 'grid'){ |
52 | $this->grid_cols_min_width = 250; | 51 | $this->grid_cols_min_width = 250; |
53 | } | 52 | } |
54 | } | 53 | } |
@@ -75,11 +74,11 @@ class NodeData | |||
75 | unset($this->data[$key]); | 74 | unset($this->data[$key]); |
76 | } | 75 | } |
77 | } | 76 | } |
78 | public function getPresentation(): ?Presentation | 77 | public function getPresentation(): ?string |
79 | { | 78 | { |
80 | return $this->presentation; | 79 | return $this->presentation; |
81 | } | 80 | } |
82 | public function setPresentation(Presentation $presentation): void | 81 | public function setPresentation(string $presentation): void |
83 | { | 82 | { |
84 | $this->presentation = $presentation; | 83 | $this->presentation = $presentation; |
85 | } | 84 | } |
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 @@ | |||
1 | <?php | ||
2 | // src/model/entities/Presentation.php | ||
3 | |||
4 | declare(strict_types=1); | ||
5 | |||
6 | namespace App\Entity; | ||
7 | |||
8 | use Doctrine\ORM\EntityManager; | ||
9 | use Doctrine\ORM\Mapping as ORM; | ||
10 | |||
11 | #[ORM\Entity] | ||
12 | #[ORM\Table(name: TABLE_PREFIX . "presentation")] | ||
13 | class Presentation | ||
14 | { | ||
15 | static public array $option_list = ['fullwidth' => 'Pleine largeur', 'grid' => 'Grille', 'mosaic' => 'Mosaïque', 'carousel' => 'Carrousel']; | ||
16 | |||
17 | #[ORM\Id] | ||
18 | #[ORM\GeneratedValue] | ||
19 | #[ORM\Column(type: "integer")] | ||
20 | private int $id_presentation; | ||
21 | |||
22 | #[ORM\Column(type: "string", length: 255)] | ||
23 | private string $name; | ||
24 | |||
25 | public function __construct(string $name) | ||
26 | { | ||
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 | } | ||
33 | } | ||
34 | |||
35 | public function getName(): string | ||
36 | { | ||
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(); | ||
46 | } | ||
47 | } \ No newline at end of file | ||