/** * Retourne le contenu de la vue et ajoute le layout * si celui-ci a été défini. * @param String $file Représente la vue à utiliser. * @return String */ public function view($file) { $file = str_replace('.', DS, $file); // Si ce n'est pas une redirection if ($this->redirect === null) { // Récupération du content de la view $content = $this->_view->content('Views' . DS . $file . '.php', 'content'); // Récupération du layout if ($this->layout) { $content = $this->_view->content('Views' . DS . 'Layout' . DS . $this->layout . '.php', 'content'); } return $content; } return ''; }
/** * Return a response to send using an exception. * * @param MerciKIException e The thrown exception. * @return The response to send. */ protected function _catchException(MerciKIException $e) { $code = $e->getCode(); if ($code == null) { $code = 500; } try { $view = new View(); $view->addVars(['message' => $e->getMessage(), 'code' => $code]); $content = $view->content('Views' . DS . 'Exception' . DS . $e->getViewFileName() . '.php', 'content'); if ($e->getLayoutFileName()) { $content = $view->content('Views' . DS . 'Layout' . DS . $e->getLayoutFileName() . '.php'); } } catch (ViewNotExist $v) { $content = '<!DOCTYPE html><html><head><title>ERROR</title></head><body>' . 'No view found for this exception : ' . $code . ' - ' . $e->getMessage() . '</body></html>'; } catch (MerciKIException $m) { return $this->_catchException($m); } return new HtmlResponse($content, $code); }