diff options
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/Blocks.php | 38 | ||||
-rw-r--r-- | src/model/entities/Article.php | 2 | ||||
-rw-r--r-- | src/model/entities/NodeData.php | 12 | ||||
-rw-r--r-- | src/model/entities/Presentation.php | 31 |
4 files changed, 83 insertions, 0 deletions
diff --git a/src/model/Blocks.php b/src/model/Blocks.php new file mode 100644 index 0000000..f6475cd --- /dev/null +++ b/src/model/Blocks.php | |||
@@ -0,0 +1,38 @@ | |||
1 | <?php | ||
2 | // src/Blocks.php | ||
3 | |||
4 | class Blocks{ | ||
5 | /*private array $types = ['blog', 'grid', 'calendar', 'galery', 'form'];*/ | ||
6 | static private array $types = ['post_block', 'news_block', 'calendar', 'galery', 'form']; | ||
7 | |||
8 | /*private array $names = ['Blog', 'Grille', 'Calendrier', 'Galerie', 'Formulaire'];*/ | ||
9 | static private array $names = ['Articles libres', 'Actualités', 'Calendrier', 'Galerie', '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 | ||
diff --git a/src/model/entities/Article.php b/src/model/entities/Article.php index 14028ec..5412497 100644 --- a/src/model/entities/Article.php +++ b/src/model/entities/Article.php | |||
@@ -1,5 +1,7 @@ | |||
1 | <?php | 1 | <?php |
2 | // src/model/entities/Article.php | 2 | // src/model/entities/Article.php |
3 | // | ||
4 | // entité commune pour les "post" (articles simples) et les "news" (complexes avec titre, aperçu et contenu) | ||
3 | 5 | ||
4 | declare(strict_types=1); | 6 | declare(strict_types=1); |
5 | 7 | ||
diff --git a/src/model/entities/NodeData.php b/src/model/entities/NodeData.php index 758ccb7..c835727 100644 --- a/src/model/entities/NodeData.php +++ b/src/model/entities/NodeData.php | |||
@@ -24,6 +24,10 @@ 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\ManyToOne(targetEntity: Presentation::class)] | ||
28 | #[ORM\JoinColumn(name: "presentation_id", referencedColumnName: "id_presentation", nullable: true)] | ||
29 | private Presentation $presentation; | ||
30 | |||
27 | #[ORM\Column(type: "json")] | 31 | #[ORM\Column(type: "json")] |
28 | private array $data; | 32 | private array $data; |
29 | 33 | ||
@@ -47,6 +51,14 @@ class NodeData | |||
47 | { | 51 | { |
48 | return $this->id_node_data; | 52 | return $this->id_node_data; |
49 | } | 53 | } |
54 | public function getPresentation(): Presentation | ||
55 | { | ||
56 | return $this->presentation; | ||
57 | } | ||
58 | public function setPresentation(Presentation $presentation): void | ||
59 | { | ||
60 | $this->presentation = $presentation; | ||
61 | } | ||
50 | public function getData(): array | 62 | public function getData(): array |
51 | { | 63 | { |
52 | return $this->data; | 64 | return $this->data; |
diff --git a/src/model/entities/Presentation.php b/src/model/entities/Presentation.php new file mode 100644 index 0000000..73b6a6a --- /dev/null +++ b/src/model/entities/Presentation.php | |||
@@ -0,0 +1,31 @@ | |||
1 | <?php | ||
2 | // src/model/entities/Presentation.php | ||
3 | |||
4 | declare(strict_types=1); | ||
5 | |||
6 | namespace App\Entity; | ||
7 | |||
8 | use Doctrine\ORM\Mapping as ORM; | ||
9 | |||
10 | #[ORM\Entity] | ||
11 | #[ORM\Table(name: TABLE_PREFIX . "presentation")] | ||
12 | class Presentation | ||
13 | { | ||
14 | #[ORM\Id] | ||
15 | #[ORM\GeneratedValue] | ||
16 | #[ORM\Column(type: "integer")] | ||
17 | private int $id_presentation; | ||
18 | |||
19 | #[ORM\Column(type: "string", length: 255)] | ||
20 | private string $name_presentation; | ||
21 | |||
22 | public function __construct(string $name) | ||
23 | { | ||
24 | $this->name_presentation = $name; | ||
25 | } | ||
26 | |||
27 | public function getName(): string | ||
28 | { | ||
29 | return $this->name_presentation; | ||
30 | } | ||
31 | } \ No newline at end of file | ||