From c371fe764b0f5ff1a60197053996c418cde1452f Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Fri, 30 Oct 2015 11:07:20 +1030 Subject: [PATCH] Update API relationship serializer/listener --- extensions/tags/src/Api/Serializer/TagSerializer.php | 12 ++++++------ .../src/Listener/AddDiscussionTagsRelationship.php | 4 ++-- .../tags/src/Listener/AddForumTagsRelationship.php | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/extensions/tags/src/Api/Serializer/TagSerializer.php b/extensions/tags/src/Api/Serializer/TagSerializer.php index b51ee97c2..9a775bdef 100644 --- a/extensions/tags/src/Api/Serializer/TagSerializer.php +++ b/extensions/tags/src/Api/Serializer/TagSerializer.php @@ -50,18 +50,18 @@ class TagSerializer extends AbstractSerializer } /** - * @return \Flarum\Api\Relationship\HasOneBuilder + * @return \Tobscure\JsonApi\Relationship */ - protected function parent() + protected function parent($tag) { - return $this->hasOne(TagSerializer::class); + return $this->hasOne($tag, TagSerializer::class); } /** - * @return \Flarum\Api\Relationship\HasOneBuilder + * @return \Tobscure\JsonApi\Relationship */ - protected function lastDiscussion() + protected function lastDiscussion($tag) { - return $this->hasOne(DiscussionSerializer::class); + return $this->hasOne($tag, DiscussionSerializer::class); } } diff --git a/extensions/tags/src/Listener/AddDiscussionTagsRelationship.php b/extensions/tags/src/Listener/AddDiscussionTagsRelationship.php index 5bffa4b1e..d63d97d13 100755 --- a/extensions/tags/src/Listener/AddDiscussionTagsRelationship.php +++ b/extensions/tags/src/Listener/AddDiscussionTagsRelationship.php @@ -46,12 +46,12 @@ class AddDiscussionTagsRelationship /** * @param GetApiRelationship $event - * @return \Flarum\Api\Relationship\HasManyBuilder|null + * @return \Tobscure\JsonApi\Relationship|null */ public function getApiRelationship(GetApiRelationship $event) { if ($event->isRelationship(DiscussionSerializer::class, 'tags')) { - return $event->serializer->hasMany('Flarum\Tags\Api\Serializer\TagSerializer', 'tags'); + return $event->serializer->hasMany($event->model, 'Flarum\Tags\Api\Serializer\TagSerializer', 'tags'); } } diff --git a/extensions/tags/src/Listener/AddForumTagsRelationship.php b/extensions/tags/src/Listener/AddForumTagsRelationship.php index 724ddd99c..c7ceba820 100755 --- a/extensions/tags/src/Listener/AddForumTagsRelationship.php +++ b/extensions/tags/src/Listener/AddForumTagsRelationship.php @@ -48,12 +48,12 @@ class AddForumTagsRelationship /** * @param GetApiRelationship $event - * @return \Flarum\Api\Relationship\HasManyBuilder|null + * @return \Tobscure\JsonApi\Relationship|null */ public function getApiRelationship(GetApiRelationship $event) { if ($event->isRelationship(ForumSerializer::class, 'tags')) { - return $event->serializer->hasMany('Flarum\Tags\Api\Serializer\TagSerializer', 'tags'); + return $event->serializer->hasMany($event->model, 'Flarum\Tags\Api\Serializer\TagSerializer', 'tags'); } }