Paaxio 1.0
Plateforme de streaming musical - SAE IUT Bayonne
Chargement...
Recherche...
Aucune correspondance
index.php
Aller à la documentation de ce fichier.
1<?php
2
20require_once 'include.php';
21
22try {
23 // ==========================================
24 // RÉCUPÉRATION DES PARAMÈTRES DE ROUTAGE
25 // ==========================================
26
34 if (isset($_GET['controller'])) {
35 $controllerName = $_GET['controller'];
36 } else {
37 $controllerName = '';
38 }
39
47 if (isset($_GET['method'])) {
48 $method = $_GET['method'];
49 } else {
50 $method = '';
51 }
52
53 // ==========================================
54 // GESTION DE LA PAGE D'ACCUEIL PAR DÉFAUT
55 // ==========================================
56
63 if ($controllerName == '' && $method == '') {
64 $controllerName = 'home';
65 $method = 'afficher';
66 }
67
68 // ==========================================
69 // VALIDATION DES PARAMÈTRES
70 // ==========================================
71
77 if ($controllerName == '') {
78 throw new Exception('Le controller n\'est pas défini');
79 }
80
86 if ($method == '') {
87 throw new Exception('La méthode n\'est pas définie');
88 }
89
90 // ==========================================
91 // EXÉCUTION DE L'ACTION
92 // ==========================================
93
102 $controller = ControllerFactory::getController($controllerName, $loader, $twig);
103
110 $controller->call($method);
111} catch (Exception $e) {
120 die('Erreur : ' . $e->getMessage());
121}
static getController($controller, \Twig\Loader\FilesystemLoader $loader, \Twig\Environment $twig)
Crée et retourne une instance du contrôleur demandé.
$twig
Environnement Twig configuré
Definition twig.php:32
$loader
Chargeur de fichiers Twig.
Definition twig.php:21