Example #1
0
 /**
  * Initialize the class instance variables and then call the action.
  *
  * @param Zend_Controller_Dispatcher_Token $action
  */
 public final function run(Zend_Controller_Dispatcher_Interface $dispatcher, Zend_Controller_Dispatcher_Token $action)
 {
     $this->_action = $action;
     $this->_params = $action->getParams();
     if (!strlen($action->getActionName())) {
         $action->setActionName('index');
     }
     $methodName = $dispatcher->formatActionName($action->getActionName());
     if (!method_exists($this, $methodName)) {
         $this->__call($methodName, array());
     } else {
         $method = new ReflectionMethod($this, $methodName);
         if ($method->isPublic() && !$method->isStatic()) {
             $this->{$methodName}();
         } else {
             throw new Zend_Controller_Page_Exception('Illegal action called.');
         }
     }
     $nextAction = $this->_nextAction;
     $this->_nextAction = null;
     return $nextAction;
 }
Example #2
0
 /**
  * If $performDispatch is FALSE, this method will check if a controller
  * file exists.  This still doesn't necessarily mean that it can be dispatched
  * in the stricted sense, as file may not contain the controller class or the
  * controller may reject the action.
  *
  * If $performDispatch is TRUE, then this method will actually
  * instantiate the controller and call its action.  Calling the action
  * is done by passing a Zend_Controller_Dispatcher_Token to the controller's constructor.
  *
  * @param Zend_Controller_Dispatcher_Token $action
  * @param boolean $performDispatch
  * @return boolean|Zend_Controller_Dispatcher_Token
  */
 protected function _dispatch(Zend_Controller_Dispatcher_Token $action, $performDispatch)
 {
     if ($this->_directory === null) {
         throw new Zend_Controller_Dispatcher_Exception('Controller directory never set.  Use setControllerDirectory() first.');
     }
     $className = $this->formatControllerName($action->getControllerName());
     /**
      * If $performDispatch is FALSE, only determine if the controller file
      * can be accessed.
      */
     if (!$performDispatch) {
         return Zend::isReadable($this->_directory . DIRECTORY_SEPARATOR . $className . '.php');
     }
     Zend::loadClass($className, $this->_directory);
     $controller = new $className();
     if (!$controller instanceof Zend_Controller_Action) {
         throw new Zend_Controller_Dispatcher_Exception("Controller \"{$className}\" is not an instance of Zend_Controller_Action.");
     }
     /**
      * Dispatch
      *
      * Call the action of the Zend_Controller_Action.  It will return either null or a
      * new Zend_Controller_Dispatcher_Token object.  If a Zend_Controller_Dispatcher_Token object is returned, this will be returned
      * back to ZFrontController, which will call $this again to forward to
      * another action.
      */
     $nextAction = $controller->run($this, $action);
     // Destroy the page controller instance
     $controller = null;
     // Return either null (finished) or a Zend_Controller_Dispatcher_Token object (forward to another action).
     return $nextAction;
 }
Example #3
0
 /**
  * Runs the current action against the proper controller, recording meta data about the
  * act for future use.
  *
  * @param Zend_Controller_Action $controller The controller being executed
  * @param Zend_Controller_Dispatcher_Token $action The action within the controller
  * @return Zend_Controller_Dispatcher_Token The next token in the execution chain
  */
 protected function _runController(Zend_Controller_Action $controller, Zend_Controller_Dispatcher_Token $action)
 {
     $currentAction = strtolower($action->getActionName());
     $currentController = strtolower($action->getControllerName());
     $this->_firstAction = is_null($this->_firstAction) ? $action : $this->_firstAction;
     $nextAction = $controller->run($this, $action);
     $this->_actionList->addAction($action);
     return $nextAction;
 }