diff options
Diffstat (limited to 'src/model/Blocks.php')
| -rw-r--r-- | src/model/Blocks.php | 38 |
1 files changed, 38 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 | ||
