Exemple #1
0
 /**
  * Load the requested controller view.
  * 
  * For example, you can load another view in your controller with:
  * 
  *     $this->loadView($this->getControllerName() . '/some_other_action');
  * 
  * Or some other controller with:
  *
  *     $this->loadView('some_other_controller/some_other_action');
  * 
  * Remember, the view for your action will be rendered automatically.
  * 
  * @param string $controllerViewName 'controller_name/action_name' format.
  * @return void
  * @throws Lvc_Exception
  * @author Anthony Bush
  **/
 protected function loadView($controllerViewName)
 {
     $view = Lvc_Config::getControllerView($controllerViewName, $this->viewVars);
     if (is_null($view)) {
         throw new Lvc_Exception('Unable to load controller view "' . $controllerViewName . '" for controller "' . $this->controllerName . '"');
     } else {
         $view->setController($this);
         $viewContents = $view->getOutput();
     }
     if ($this->useLayoutOverride) {
         $this->layout = $this->layoutOverride;
     }
     if (!empty($this->layout)) {
         // Use an explicit name for this data so we don't override some other variable...
         $this->layoutVars[Lvc_Config::getLayoutContentVarName()] = $viewContents;
         $layoutView = Lvc_Config::getLayoutView($this->layout, $this->layoutVars);
         if (is_null($layoutView)) {
             throw new Lvc_Exception('Unable to load layout view "' . $this->layout . '" for controller "' . $this->controllerName . '"');
         } else {
             $layoutView->setController($this);
             $layoutView->output();
         }
     } else {
         echo $viewContents;
     }
     $this->hasLoadedView = true;
 }