1
0
mirror of https://github.com/flarum/core.git synced 2025-10-10 14:34:30 +02:00

Upgrade to JSON-API RC3 + latest version of tobscure/json-api

Note: npm source for ember-json-api changed to a fork, but I still had
to apply a custom change to get polymorphic relationships to work (see
https://github.com/kurko/ember-json-api/pull/71#issuecomment-85257281)
This commit is contained in:
Toby Zerner
2015-03-24 15:04:24 +10:30
parent 536281e273
commit a62e04f956
36 changed files with 342 additions and 503 deletions

View File

@@ -24,10 +24,10 @@ class UpdateAction extends BaseAction
// discussion's direct properties; by default, this is just the title.
// As usual, however, we will fire an event to allow plugins to update
// additional properties.
if ($data = array_except($params->get('discussions'), ['readNumber'])) {
if ($data = array_except($params->get('data'), ['readNumber'])) {
try {
$command = new EditDiscussionCommand($discussionId, $user);
$this->hydrate($command, $params->get('discussions'));
$this->hydrate($command, $params->get('data'));
$discussion = $this->dispatch($command, $params);
} catch (PermissionDeniedException $e) {
// Temporary fix. See @todo below
@@ -43,7 +43,7 @@ class UpdateAction extends BaseAction
// PermissionDeniedException is thrown by the
// EditDiscussionCommand above. So this needs to be extracted into
// its own endpoint.
if ($readNumber = $params->get('discussions.readNumber')) {
if ($readNumber = $params->get('data.readNumber')) {
$command = new ReadDiscussionCommand($discussionId, $user, $readNumber);
$this->dispatch($command, $params);
}
@@ -52,7 +52,7 @@ class UpdateAction extends BaseAction
// handlers would have thrown an exception if not.) We set this
// discussion as our document's primary element.
$serializer = new DiscussionSerializer(['addedPosts', 'addedPosts.user']);
$document = $this->document()->setPrimaryElement($serializer->resource($discussion));
$document = $this->document()->setData($serializer->resource($discussion));
return $this->respondWithDocument($document);
}