/** * @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); } }
/** * 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()); } }
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; } }
public function dispatch($action) { if (Zend_Registry::get('requestIsAjax')) { $this->_helper->layout->disableLayout(); } parent::dispatch($action); }
/** * 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; } }
/** * 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()); } }
/** * (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)); }