Skip to content

Commit

Permalink
Update phpdoc, catch all exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
BafS committed Aug 3, 2016
1 parent 9fa4c99 commit 2003077
Showing 1 changed file with 11 additions and 27 deletions.
38 changes: 11 additions & 27 deletions app/routes/api/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Parvula\Models\PagesFlatFiles;
use Parvula\Exceptions\IOException;
use Rs\Json\Patch;
use Rs\Json\Patch\InvalidOperationException;
use Rs\Json\Patch\InvalidPatchDocumentJsonException;
use Rs\Json\Patch\InvalidTargetDocumentJsonException;
use Rs\Json\Patch\InvalidOperationException;

$pages = $app['pages'];

Expand Down Expand Up @@ -136,34 +136,17 @@

/**
* @api {patch} /pages/:slug Update specific field(s) of a page
* @apiDescription For more details about json patch: https://tools.ietf.org/html/rfc6902
* @apiName Patch page
* @apiGroup Page
*
* @apiParamExample Request-Example:
* title=My new title
*
* @apiParamExample Request-Example:
* title=My new title&content=new content
*
* @apiSuccess (204) PagePatched
* @apiError (400) InvalidPatchDocumentJsonException
* @apiError (400) InvalidTargetDocumentJsonException
* @apiError (400) InvalidOperationException
* @apiError (404) PageDoesNotExists If page does not exists
* @apiError (404) PageException If exception
*/
// $this->patch('/{slug:.+}', function ($req, $res, $args) use ($pages) {
// $pageArr = (array) $req->getParsedBody();
//
// try {
// $pages->patch($args['slug'], $pageArr);
// } catch (Exception $e) {
// return $this->api->json($res, [
// 'error' => 'PageException',
// 'message' => $e->getMessage()
// ], 500);
// }
//
// return $res->withStatus(204);
// });

// DEV
$this->patch('/{slug:.+}', function ($req, $res, $args) use ($app, $pages) {
$parsedBody = $req->getParsedBody();
$bodyJson = json_encode($req->getParsedBody());
Expand Down Expand Up @@ -208,13 +191,14 @@
'error' => 'InvalidOperationException',
'message' => $e->getMessage()
], 400);
} catch (Exception $e) {
return $this->api->json($res, [
'error' => 'InvalidOperationException',
'message' => $e->getMessage()
], 500);
}
});





/*
* @api {delete} /page/:slug Delete a page.
* @apiName Delete page
Expand Down

0 comments on commit 2003077

Please sign in to comment.