Example #1
0
 /**
  * Use this inside a controller action to get the output from another
  * controller's action. By default, the layout functionality will be
  * disabled for this "sub" action.
  * 
  * Example Usage:
  * 
  *     $enrollmentVerifyBox = $this->requestAction('enrollment_verify', array(), 'eligibility');
  * 
  * @param string $actionName name of action to invoke.
  * @param array $actionParams parameters to invoke the action with.
  * @param string $controllerName optional controller name. Current controller will be used if not specified.
  * @param array $controllerParams optional controller params. Current controller params will be passed on if not specified.
  * @param string $layout optional layout to force for the sub action.
  * @return string output from requested controller's action.
  * @throws Lvc_Exception
  * @author Anthony Bush
  **/
 protected function requestAction($actionName, $actionParams = array(), $controllerName = null, $controllerParams = null, $layout = null)
 {
     if (empty($controllerName)) {
         $controllerName = $this->controllerName;
     }
     if (is_null($controllerParams)) {
         $controllerParams = $this->params;
     }
     $controller = Lvc_Config::getController($controllerName);
     if (is_null($controller)) {
         throw new Lvc_Exception('Unable to load controller "' . $controllerName . '"');
     }
     $controller->setControllerParams($controllerParams);
     $controller->setLayoutOverride($layout);
     return $controller->getActionOutput($actionName, $actionParams);
 }