/** * Init * * @return void */ public function init() { $this->autoload_files(); if (craft()->config->get('paginationParameter', 'restfulApi') === craft()->config->get('pageTrigger')) { $exception = new RestfulApiException(); $exception->setMessage('The `paginationParameter` cannot be the same as `pageTrigger`.'); throw $exception; } }
/** * Resource Router * * @param array $variables Variables * * @return void */ public function actionResourceRouter(array $variables = []) { try { $this->dispatcher->handle($this, $variables); return $this->response->send(); } catch (RestfulApiException $exception) { $exception->setInput($this->request->getParsedBody()); $response = new Response(); return $response->setStatus($exception->getStatusCode(), $exception->getStatusPhrase())->setError($exception)->send(); } catch (CDbException $CDbException) { $exception = new RestfulApiException(); $exception->setMessage($CDbException->getMessage()); $response = new Response(); return $response->setError($exception)->send(); } catch (\Craft\Exception $craftException) { $exception = new RestfulApiException(); $exception->setMessage($craftException->getMessage()); $response = new Response(); return $response->setError($exception)->send(); } }