diff options
author | polo <ordipolo@gmx.fr> | 2025-09-01 18:52:17 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2025-09-01 18:52:17 +0200 |
commit | f477314613beb26b0ce4c61ec0b1900df1de1cb1 (patch) | |
tree | d41ace78a572a11887e7cfa2611c3f02fb04e51c /src/model/entities | |
parent | e642cd51d7e8599537f8514bef8d5d16096dddf8 (diff) | |
download | cms-f477314613beb26b0ce4c61ec0b1900df1de1cb1.zip |
renommage des présentations,modif présentation des blocs et largeur min (donc nb de colonnes) en mode grid, corrections de bugs et erreurs 404, le param page_modif n'est plus une action, légère symfonyfication du routeur
Diffstat (limited to 'src/model/entities')
-rw-r--r-- | src/model/entities/Node.php | 9 | ||||
-rw-r--r-- | src/model/entities/NodeData.php | 40 | ||||
-rw-r--r-- | src/model/entities/Presentation.php | 22 |
3 files changed, 56 insertions, 15 deletions
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 | |||
161 | { | 161 | { |
162 | return $this->children; | 162 | return $this->children; |
163 | } | 163 | } |
164 | public function getNodeByName(string $name): ?Node | ||
165 | { | ||
166 | foreach($this->children as $child){ | ||
167 | if($child->getName() === $name){ | ||
168 | return $child; | ||
169 | } | ||
170 | } | ||
171 | return null; | ||
172 | } | ||
164 | public function addChild(self $child): void | 173 | public function addChild(self $child): void |
165 | { | 174 | { |
166 | $this->children[] = $child; | 175 | $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 | |||
24 | #[ORM\JoinColumn(name: "node_id", referencedColumnName: "id_node", onDelete: "CASCADE")] | 24 | #[ORM\JoinColumn(name: "node_id", referencedColumnName: "id_node", onDelete: "CASCADE")] |
25 | private Node $node; | 25 | private Node $node; |
26 | 26 | ||
27 | #[ORM\Column(type: "json")] | ||
28 | private array $data; | ||
29 | |||
27 | #[ORM\ManyToOne(targetEntity: Presentation::class)] | 30 | #[ORM\ManyToOne(targetEntity: Presentation::class)] |
28 | #[ORM\JoinColumn(name: "presentation_id", referencedColumnName: "id_presentation", nullable: true)] | 31 | #[ORM\JoinColumn(name: "presentation_id", referencedColumnName: "id_presentation", nullable: true)] |
29 | private Presentation $presentation; | 32 | private ?Presentation $presentation; |
30 | 33 | ||
31 | #[ORM\Column(type: "json")] | 34 | #[ORM\Column(type: "integer", length: 255, nullable: true)] |
32 | private array $data; | 35 | private ?int $grid_cols_min_width = null; // pour le mode grille |
33 | 36 | ||
34 | // liaison avec table intermédiaire | 37 | // liaison avec table intermédiaire |
35 | #[ORM\ManyToMany(targetEntity: Image::class, inversedBy: "node_data")] | 38 | #[ORM\ManyToMany(targetEntity: Image::class, inversedBy: "node_data")] |
@@ -40,25 +43,20 @@ class NodeData | |||
40 | )] | 43 | )] |
41 | private Collection $images; | 44 | private Collection $images; |
42 | 45 | ||
43 | public function __construct(array $data, Node $node, Collection $images = new ArrayCollection) | 46 | public function __construct(array $data, Node $node, Collection $images = new ArrayCollection, Presentation $presentation = null) |
44 | { | 47 | { |
45 | $this->data = $data; | 48 | $this->data = $data; |
46 | $this->node = $node; | 49 | $this->node = $node; |
47 | $this->images = $images; | 50 | $this->images = $images; |
51 | if(!empty($presentation) && $presentation->getName() === 'grid'){ | ||
52 | $this->grid_cols_min_width = 250; | ||
53 | } | ||
48 | } | 54 | } |
49 | 55 | ||
50 | public function getId(): int | 56 | public function getId(): int |
51 | { | 57 | { |
52 | return $this->id_node_data; | 58 | return $this->id_node_data; |
53 | } | 59 | } |
54 | public function getPresentation(): Presentation | ||
55 | { | ||
56 | return $this->presentation; | ||
57 | } | ||
58 | public function setPresentation(Presentation $presentation): void | ||
59 | { | ||
60 | $this->presentation = $presentation; | ||
61 | } | ||
62 | public function getData(): array | 60 | public function getData(): array |
63 | { | 61 | { |
64 | return $this->data; | 62 | return $this->data; |
@@ -77,6 +75,24 @@ class NodeData | |||
77 | unset($this->data[$key]); | 75 | unset($this->data[$key]); |
78 | } | 76 | } |
79 | } | 77 | } |
78 | public function getPresentation(): ?Presentation | ||
79 | { | ||
80 | return $this->presentation; | ||
81 | } | ||
82 | public function setPresentation(Presentation $presentation): void | ||
83 | { | ||
84 | $this->presentation = $presentation; | ||
85 | } | ||
86 | public function getColsMinWidth(): int | ||
87 | { | ||
88 | $default = 320; // pixels | ||
89 | return $this->grid_cols_min_width === null ? $default : $this->grid_cols_min_width; | ||
90 | } | ||
91 | public function setColsMinWidth(int $columns): void | ||
92 | { | ||
93 | $this->grid_cols_min_width = $columns; | ||
94 | } | ||
95 | |||
80 | /*public function setNode(Node $node): void | 96 | /*public function setNode(Node $node): void |
81 | { | 97 | { |
82 | $this->node = $node; | 98 | $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); | |||
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 |