Ejemplo n.º 1
0
 /**
  * @param string $action
  * @return Api_Controller_Response_Result
  * @throws Api_Exception_BadMethodCall
  */
 public function dispatch($action)
 {
     try {
         $action = $this->_getRestAction();
         if (!$action) {
             throw new Api_Exception_BadMethodCall();
         }
         $this->_request->setActionName($action);
         $dto = $this->_dtoManager->createFromMethod($this, $action . 'Action');
         if (!$dto) {
             parent::dispatch($action . 'Action');
             $result = $this->_getDispatchedResult();
         } else {
             $this->_annotationManager->populateDtoFromArray($dto, $this->_getParams());
             $result = call_user_func_array([$this, $action . 'Action'], [$dto]);
         }
     } catch (Api_Exception_BadMethodCall $e) {
         $result = $this->_createError('not found', Api_Controller_Response_Result::NOT_FOUND);
     } catch (Api_Exception_NoArgument $e) {
         $result = $this->_createError($e->getMessage(), Api_Controller_Response_Result::BAD_REQUEST);
     } catch (Exception $e) {
         $result = $this->_createError('internal error', Api_Controller_Response_Result::INTERNAL);
     }
     $this->_response->setHttpResponseCode($result->getCode());
     if ($result->getCode() != Api_Controller_Response_Result::NO_CONTENT) {
         if ($result->getLocation()) {
             $this->_response->setHeader('Location', $result->getLocation());
         }
         $raw = $this->_getRawResult($result);
         $this->_helper->json($raw);
     }
 }
Ejemplo n.º 2
0
 /**
  * Checks to see whether or not there needs to be any request method
  * filtering before executing $action.
  * 
  * @param string $action Method name of action
  * @return void
  */
 public function dispatch($action)
 {
     try {
         $this->filterRequest($action);
         $this->validateRequestAction($action);
         parent::dispatch($action);
     } catch (Exception $e) {
         // add a 500 header
         if (!headers_sent()) {
             header('HTTP/1.1 500 Internal Server Error');
             echo $e->getMessage();
         }
         throw $e;
     }
 }
 /**
  * cheezy way of handling exceptions for all actions
  */
 public function dispatch($action)
 {
     parent::dispatch($action);
     return;
     try {
         parent::dispatch($action);
     } catch (exception $e) {
         ob_start();
         var_export($e);
         error_log(ob_get_clean());
     }
 }
Ejemplo n.º 4
0
 public function dispatch($action)
 {
     try {
         parent::dispatch($action);
         $this->addInfoMessages();
         $this->addSuccessMessages();
     } catch (Core_Exception_Validation $exc) {
         $this->_persistDataError();
         $this->addErrorMessages();
         $this->addAlertMessages();
         $this->getMessaging()->dispatchPackets();
         $this->_dispatchException($action, $exc);
     } catch (Core_Exception_Verification $exc) {
         $this->_persistDataError();
         $this->addErrorMessages();
         $this->addAlertMessages();
         $this->getMessaging()->dispatchPackets();
         $this->_dispatchException($action, $exc);
     } catch (Core_Exception $exc) {
         throw $exc;
     } catch (Exception $exc) {
         throw $exc;
     }
 }
Ejemplo n.º 5
0
 public function dispatch($action)
 {
     if (Zend_Registry::get('requestIsAjax')) {
         $this->_helper->layout->disableLayout();
     }
     parent::dispatch($action);
 }
Ejemplo n.º 6
0
 /**
  * Dispatch the requested action
  *
  * @param string $action Method name of action
  * @return void
  */
 public function dispatch($action)
 {
     try {
         parent::dispatch($action);
     } catch (Exception $e) {
         $cachePage = $this->getInvokeArg('bootstrap')->getResource('cachemanager')->getCache('_page');
         if (null !== $cachePage && method_exists($cachePage, 'cancel')) {
             $cachePage->cancel();
         }
         $cachePage = $this->getInvokeArg('bootstrap')->getResource('cachemanager')->getCache('page');
         if (null !== $cachePage && method_exists($cachePage, 'cancel')) {
             $cachePage->cancel();
         }
         throw $e;
     }
 }
Ejemplo n.º 7
0
 /**
  * Dispatch the requested action
  *
  * @param string $action Method name of action
  * @return void
  */
 public function dispatch($action)
 {
     $dbAdapter = Zend_Registry::getInstance()->dbAdapter;
     try {
         parent::dispatch($action);
     } catch (Exception $e) {
         $this->getLogger()->err($e->getMessage() . $e->getTraceAsString());
     }
 }
Ejemplo n.º 8
0
 /**
  * (non-PHPdoc)
  * @see Zend_Controller_Action::dispatch()
  */
 public function dispatch($action)
 {
     $action = substr($action, 0, -6);
     $format = '';
     for ($i = strlen($action) - 1; $i >= 0; $i--) {
         $format = $action[$i] . $format;
         $code = ord($action[$i]);
         if ($code >= 65 && $code <= 90) {
             break;
         }
     }
     $format = strtolower($format);
     if (in_array($format, $this->_responseFormats)) {
         $action = substr($action, 0, -1 * strlen($format));
     } else {
         $format = 'json';
     }
     $this->_setParam('responseformat', $format);
     parent::dispatch($action . 'Action');
 }
 public function dispatch($action)
 {
     try {
         parent::dispatch($action);
     } catch (Exception $ex) {
         return;
     }
     $this->view->currentAction = $action;
     $this->view->cssLinks = $this->_cssLinks;
     $this->view->jsLinks = $this->_jsLinks;
 }
 /**
  * Dispatches the action with the given name:
  *
  * Example:
  *
  *     $this->dispatch('my-action');
  *
  * @param string $action
  */
 protected function dispatch($action)
 {
     $this->request->setActionName($action);
     $this->controller->dispatch($this->actionNameToMethod($action));
 }