Skip to content

Commit

Permalink
small adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
ahilles107 committed Jan 8, 2015
1 parent aaa3d80 commit ace3002
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions features/0_api_articles.feature
Expand Up @@ -41,10 +41,10 @@ Feature: Endpoints
| onFrontPage | 1 ||
| onSection | 1 ||
| keywords | test keywords | 30 |
| fields[lead] | <<sentence>> | 15 |
| fields[content] | <<sentence>> | 35 |
| fields[content] | <<sentence>> | 35 |

When I submit "article" data to "<<new_article>>"
Then echo last response
Then the response status code should be 200
And the response is JSON
And field "keywords" in the response should be "test keywords"
Expand Up @@ -120,9 +120,7 @@ public function createArticleAction(Request $request)
*
* fields: array with article type fields and ther values.
*
* article[fields][Flead] = 'new lead'
*
* field name is composed from "F"+"field_name": "Flead", "Fbody"
* article[fields][lead] = 'new lead'
*
* @ApiDoc(
* statusCodes={
Expand Down Expand Up @@ -176,13 +174,7 @@ public function patchArticleAction(Request $request, $number, $language)
// TODO add support for global for errors handler
}

// Temporarily added to at least give some feedback,
// without it the status would always be 500
// @Author: Mischa
$response = new Response();
$response->setStatusCode(201);

return $response;
return new FOSView\View($form, 400);
}

private function postAddUpdate($article)
Expand Down
Expand Up @@ -37,7 +37,9 @@ public function onResponse(FilterResponseEvent $event)
// HACK: revert exception status code to main request (i have no idea why it's chnaged to 500)
if (is_array($content = json_decode($response->getContent(), true))) {
if (array_key_exists('errors', $content)) {
$response->setStatusCode($content['errors'][0]['code'], $content['errors'][0]['message']);
if (isset($content['errors'][0]['code'])) {
$response->setStatusCode($content['errors'][0]['code'], $content['errors'][0]['message']);
}
}
}

Expand Down

0 comments on commit ace3002

Please sign in to comment.