Skip to content

Commit

Permalink
Updates related to keeko core
Browse files Browse the repository at this point in the history
  • Loading branch information
gossi committed Dec 21, 2014
1 parent fb4377d commit 4debdc6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions .buildpath
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<buildpathentry kind="src" path="vendor/psr/log"/>
<buildpathentry kind="src" path="src"/>
<buildpathentry kind="src" path="vendor/symfony/finder"/>
<buildpathentry kind="src" path="core/database"/>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
<buildpathentry kind="src" path="vendor/symfony/process"/>
<buildpathentry kind="src" path="vendor/symfony/validator"/>
Expand Down
2 changes: 1 addition & 1 deletion .settings/org.eclipse.wst.validation.prefs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
disabled=06vendor111core/vendor
disabled=113core/database06vendor111core/vendor
eclipse.preferences.version=1
27 changes: 20 additions & 7 deletions src/ApiApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ class ApiApplication extends AbstractApplication {
/* (non-PHPdoc)
* @see \keeko\core\application\AbstractApplication::run()
*/
public function run(Request $request, $path) {
public function run(Request $request) {

$response = new JsonResponse();
$router = new ApiRouter($request, ['basepath' => $this->getAppPath()]);

try {
$path = str_replace('//', '/', '/' . $path);
$path = str_replace('//', '/', '/' . $this->getDestinationPath());
$match = $router->match($path);

$action = $match['action'];
Expand All @@ -54,20 +54,33 @@ public function run(Request $request, $path) {

$action->setParams(array_merge($params, $match, $body));

return $action->run($request);
} catch (ResourceNotFoundException $e) {
return $this->runAction($action, $request);
}

// 404 - Resource not found
catch (ResourceNotFoundException $e) {
$response->setStatusCode(Response::HTTP_NOT_FOUND);
$response->setData($this->exceptionToJson($e));
} catch (PermissionDeniedException $e) {
}

// 403 - Permission denied
catch (PermissionDeniedException $e) {
$response->setStatusCode($e->getCode());
$response->setData($this->exceptionToJson($e));
} catch (MethodNotAllowedException $e) {
}

// 405 - Method not allowed
catch (MethodNotAllowedException $e) {
$response->setStatusCode(Response::HTTP_METHOD_NOT_ALLOWED);
$response->setData($this->exceptionToJson($e));
} catch (\Exception $e) {
}

// 500 - Internal Server error
catch (\Exception $e) {
$response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
$response->setData($this->exceptionToJson($e));
}

return $response;
}

Expand Down

0 comments on commit 4debdc6

Please sign in to comment.