Exemple #1
0
 /**
  * create the path/to/folder for diferante view
  * @return void 
  */
 public function makePath()
 {
     $this->layoutPath = Config::layoutDir() . DS . $this->layout . '.ctp';
     if (!file_exists($this->layoutPath)) {
         throw new \Exception("the layout file : {$this->layoutPath} does not exist", 601);
     }
     $viewFolder = str_replace('Controller', '', $this->request->controller);
     $viewFolder = $this->toDash($viewFolder);
     $action = $this->toDash($this->request->action);
     $this->viewPath = Config::viewDir() . DS . $viewFolder . DS . $action . '.ctp';
     if (!file_exists($this->viewPath)) {
         throw new \Exception("the view file : {$this->viewPath} does not exist", 601);
     }
 }
Exemple #2
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;
 }