/**
  * Initialize the RentingController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $url .= '&id=ukn';
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'RentingController') {
             if (file_exists(_CARAVANS_VIEWS_ . '/' . $this->view_name . '.tpl')) {
                 try {
                     echo $this->twig->render($this->view_name . '.tpl', array('bootstrapPath' => _BOOTSTRAP_FILE_));
                 } catch (Exception $e) {
                     throw new Exception('Une erreur est survenue durant l\'affichage des données: ' . $e->getMessage());
                 }
             } else {
                 throw new Exception('Le template "' . $this->view_name . '" n\'existe pas dans "' . _CARAVANS_VIEWS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }
 /**
  * Initialize the ConfirmAddController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $url .= '&id=ukn';
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'ConfirmAddController') {
             if (file_exists(_CARAVANS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 try {
                     require_once _CARAVANS_MODELS_ . '/' . $this->model_name . 'Model.php';
                     Tools::getInstance()->createPost($_POST);
                     if (!empty($_POST['name']) && !empty($_POST['price']) && !empty($_POST['person']) && !empty($_POST['location'])) {
                         \Caravan\RentingModel::getInstance()->renting_caravan($_POST['name'], $_POST['price'], $_POST['person'], $_POST['location']);
                         header('Location: /Cas-M-Ping/caravans/show/all');
                     } else {
                         header('Location: /Cas-M-Ping/caravans/renting');
                     }
                 } catch (Exception $e) {
                     throw new Exception('Une erreur est survenue durant la modification des données: ' . $e->getMessage());
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _CARAVANS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }
 /**
  * Initialize the DisplayController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'DisplayController') {
             if (file_exists(_CARAVANS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 if (file_exists(_CARAVANS_VIEWS_ . '/' . $this->view_name . '.tpl')) {
                     try {
                         require_once _CARAVANS_MODELS_ . '/' . $this->model_name . 'Model.php';
                         $id = Tools::getInstance()->getUrl_id($url);
                         switch ($id) {
                             case 'all':
                                 $data = \Caravan\DisplayModel::getInstance()->display_caravans();
                                 break;
                             default:
                                 if (\Caravan\DisplayModel::getInstance()->has_Caravan($id) == 1) {
                                     $data = \Caravan\DisplayModel::getInstance()->display_caravan($id);
                                 } else {
                                     header('Location: /Cas-M-Ping/errors/404');
                                 }
                                 break;
                         }
                         echo $this->twig->render($this->view_name . '.tpl', array('caravans' => $data, 'bootstrapPath' => _BOOTSTRAP_FILE_));
                     } catch (Exception $e) {
                         throw new Exception('Une erreur est survenue durant la récupération des données: ' . $e->getMessage());
                     }
                 } else {
                     throw new Exception('Le template "' . $this->view_name . '" n\'existe pas dans "' . _CARAVANS_VIEWS_ . '"!');
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _CARAVANS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }
 /**
  * Initialize the CaravanController class
  */
 public function init()
 {
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     if (file_exists(_TWIG_AUTOLOADER_)) {
         try {
             require_once _TWIG_AUTOLOADER_;
             Twig_Autoloader::register();
             $loader = new Twig_Loader_Filesystem(array(_DEPENDENCIES_DIR_, _CARAVANS_VIEWS_));
             $this->twig = new Twig_Environment($loader, array('cache' => _TWIG_CACHE_));
         } catch (Exception $e) {
             throw new Exception('Le fichier de démarrage Twig ne peut pas s\'executer!');
         }
     } else {
         throw new Exception('Il n\'existe pas le fichier de démarrage Twig à cet emplacement "' . _TWIG_AUTOLOADER_ . '"!');
     }
 }
 /**
  * Initialize the ReturnController class and their parents
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     if (file_exists(_CONTROLLERS_DIR_ . '/Tools.php')) {
         $url = Tools::getInstance()->request_url;
         $controller = Tools::getInstance()->getUrl_controller($url);
         if ($controller == 'ReturnController') {
             if (file_exists(_CARAVANS_MODELS_ . '/' . $this->model_name . 'Model.php')) {
                 try {
                     require_once _CARAVANS_MODELS_ . '/' . $this->model_name . 'Model.php';
                     $id = Tools::getInstance()->getUrl_id($url);
                     switch ($id) {
                         case 'all':
                             \Caravan\ReturnModel::getInstance()->delete_caravans();
                             break;
                         default:
                             if (\Caravan\ReturnModel::getInstance()->has_Caravan($id) == 1) {
                                 \Caravan\ReturnModel::getInstance()->delete_caravan($id);
                             } else {
                                 header('Location: /Cas-M-Ping/errors/404');
                             }
                             break;
                     }
                     header('Location: /Cas-M-Ping/caravans/show/all');
                 } catch (Exception $e) {
                     throw new Exception('Une erreur est survenue durant la modification des données: ' . $e->getMessage());
                 }
             } else {
                 throw new Exception('Le modèle "' . $this->model_name . '" n\'existe pas dans "' . _CARAVANS_MODELS_ . '"!');
             }
         } else {
             throw new Exception('Une erreur est survenue durant la phase de routage!');
         }
     } else {
         throw new Exception('L\'URL n\'est pas évaluable!');
     }
 }