Beispiel #1
0
 public function __construct()
 {
     try {
         Config::getConf();
         Auth::loadClass();
         //we c'est un peux de la triche
         Session::start();
         EventManager::init();
         $this->request = Request::getInstance();
         $this->router = Router::getInstance();
         $this->auth = Auth::getInstance();
         include_once APP_FOLDER . DS . 'config' . DS . 'bootstrap.php';
         $this->request->securePost();
         $view = $this->router->execute();
         $view->render();
     } catch (Exception $e) {
         $this->controller = new ErrorController($e);
     }
 }
Beispiel #2
0
 /**
  * redirect the request to a new link
  * @param  array  $link a array description of the link
  */
 public function redirect($link = [])
 {
     EventManager::getInstance()->event('request.redirect', $this);
     Auth::getInstance()->notDirect();
     $url = '';
     //debug($link);
     if (is_string($link)) {
         $url = $this->url(Router::getInstance()->getRouteByName($link));
     } else {
         $url = $this->url($link);
     }
     //debug($url);
     header('Location: ' . $url);
     exit;
 }
Beispiel #3
0
 public function elementFromView($link)
 {
     $friend = Router::getInstance()->getElement($link);
     if ($friend) {
         $this->script .= $friend->script;
         $this->css .= $friend->css;
         $this->js .= $friend->js;
         $viewFolder = $this->toDash($link['controller']);
         $action = $this->toDash($link['action']);
         $friend->viewPath = Config::viewDir() . DS . $viewFolder . DS . $action . '.ctp';
         $friend->loadHelper();
         extract($friend->data);
         ob_start();
         require $friend->viewPath;
         return ob_get_clean();
     } else {
         $element = Config::getAccessDenied();
         if ($element) {
             return $this->element($element);
         }
     }
     return false;
 }