/** * * @return void|boolean */ public function send() { $output = new \PhalconRest\API\Output(); $output->setStatusCode($this->code, $this->response); $output->sendError($this->errorStore); return true; }
/** * set a standard HTTP response * * @return void|boolean */ public function send() { $output = new \PhalconRest\API\Output(); $output->setStatusCode('422', 'Unprocessable Entity'); $output->sendError($this->errorStore); return true; }
$app->after(function () use($app) { $method = $app->request->getMethod(); $output = new \PhalconRest\API\Output(); switch ($method) { case 'OPTIONS': $app->response->setStatusCode('200', 'OK'); $app->response->send(); return; break; case 'DELETE': $app->response->setStatusCode('204', 'No Content'); $app->response->send(); return; break; case 'POST': $output->setStatusCode('201', 'Created'); break; } // Results returned from the route's controller. All Controllers should return an array $records = $app->getReturnedValue(); // this is default behavior $output->convertSnakeCase(false)->send($records); return; }); /** * The notFound service is the default handler function that runs when no route was matched. * We set a 404 here unless there's a suppress error codes. */ $app->notFound(function () use($app) { throw new \PhalconRest\Util\HTTPException('Not Found.', 404, array('dev' => 'That route was not found on the server.', 'code' => '4', 'more' => 'Check route for mispellings.')); });