/** * 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(); } }
/** * Set Paginated Collection * * @param array $items Items * * @return Response Response */ public function setPaginatedCollection(array $items) { $this->setCollection($items); $this->paginator = new CraftPaginateVariableAdapter($this->request->getCriteria()); return $this; }