From 5735e09936abf0dc821b0a5fa9cb7e33d1b7b645 Mon Sep 17 00:00:00 2001 From: Marcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de> Date: Tue, 5 Oct 2021 09:04:29 +0200 Subject: [PATCH] fix #262 --- lib/classes/JsonApi/Schemas/Activity.php | 13 ++------ .../JsonApi/Schemas/BlubberComment.php | 14 +++----- lib/classes/JsonApi/Schemas/BlubberThread.php | 16 +++------ .../JsonApi/Schemas/ConsultationBlock.php | 12 ++----- .../JsonApi/Schemas/ConsultationBooking.php | 11 ++----- .../JsonApi/Schemas/ConsultationSlot.php | 12 ++----- .../JsonApi/Schemas/Courseware/Container.php | 10 +----- .../Schemas/Courseware/StructuralElement.php | 23 ++++++------- .../JsonApi/Schemas/FeedbackElement.php | 15 +++------ lib/classes/JsonApi/Schemas/FeedbackEntry.php | 15 ++++----- lib/classes/JsonApi/Schemas/Institute.php | 9 +---- lib/classes/JsonApi/Schemas/Message.php | 11 ++----- .../JsonApi/Schemas/SchemaProvider.php | 14 ++++++++ lib/classes/JsonApi/Schemas/SemClass.php | 10 +----- lib/classes/JsonApi/Schemas/StatusGroup.php | 10 +----- lib/classes/JsonApi/Schemas/StudyArea.php | 15 +++------ lib/classes/JsonApi/Schemas/User.php | 33 ++++++++----------- 17 files changed, 78 insertions(+), 165 deletions(-) diff --git a/lib/classes/JsonApi/Schemas/Activity.php b/lib/classes/JsonApi/Schemas/Activity.php index ae95e0c0ea5..607b41d011b 100644 --- a/lib/classes/JsonApi/Schemas/Activity.php +++ b/lib/classes/JsonApi/Schemas/Activity.php @@ -60,18 +60,11 @@ class Activity extends SchemaProvider */ public function getRelationships($activity, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; - $relationships = []; - $relationships = $this->getActorRelationship($relationships, $activity, $shouldInclude('actor')); - $relationships = $this->getObjectRelationship($relationships, $activity, $shouldInclude('object')); - $relationships = $this->getContextRelationship($relationships, $activity, $shouldInclude('context')); + $relationships = $this->getActorRelationship($relationships, $activity, $this->shouldInclude($context, 'actor')); + $relationships = $this->getObjectRelationship($relationships, $activity, $this->shouldInclude($context, 'object')); + $relationships = $this->getContextRelationship($relationships, $activity, $this->shouldInclude($context, 'context')); return $relationships; } diff --git a/lib/classes/JsonApi/Schemas/BlubberComment.php b/lib/classes/JsonApi/Schemas/BlubberComment.php index 2aabd5e19ea..00770237b02 100644 --- a/lib/classes/JsonApi/Schemas/BlubberComment.php +++ b/lib/classes/JsonApi/Schemas/BlubberComment.php @@ -38,22 +38,16 @@ class BlubberComment extends SchemaProvider */ public function getRelationships($resource, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; - $relationships = []; - $relationships = $this->getAuthorRelationship($relationships, $resource, $shouldInclude(self::REL_AUTHOR)); + $relationships = $this->getAuthorRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_AUTHOR)); + $isPrimary = $context->getPosition()->getLevel() === 0; if (!$isPrimary) { return $relationships; } - $relationships = $this->getMentionsRelationship($relationships, $resource, $shouldInclude(self::REL_MENTIONS)); - $relationships = $this->getThreadRelationship($relationships, $resource, $shouldInclude(self::REL_THREAD)); + $relationships = $this->getMentionsRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_MENTIONS)); + $relationships = $this->getThreadRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_THREAD)); return $relationships; } diff --git a/lib/classes/JsonApi/Schemas/BlubberThread.php b/lib/classes/JsonApi/Schemas/BlubberThread.php index 386b51e1cd1..2a7f6605587 100644 --- a/lib/classes/JsonApi/Schemas/BlubberThread.php +++ b/lib/classes/JsonApi/Schemas/BlubberThread.php @@ -50,23 +50,17 @@ class BlubberThread extends SchemaProvider */ public function getRelationships($resource, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; - $relationships = []; - $relationships = $this->getAuthorRelationship($relationships, $resource, $shouldInclude(self::REL_AUTHOR)); + $relationships = $this->getAuthorRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_AUTHOR)); + $isPrimary = $context->getPosition()->getLevel() === 0; if (!$isPrimary) { return $relationships; } - $relationships = $this->getCommentsRelationship($relationships, $resource, $shouldInclude(self::REL_COMMENTS)); - $relationships = $this->getContextRelationship($relationships, $resource, $shouldInclude(self::REL_CONTEXT)); - $relationships = $this->getMentionsRelationship($relationships, $resource, $shouldInclude(self::REL_MENTIONS)); + $relationships = $this->getCommentsRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_COMMENTS)); + $relationships = $this->getContextRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_CONTEXT)); + $relationships = $this->getMentionsRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_MENTIONS)); return $relationships; } diff --git a/lib/classes/JsonApi/Schemas/ConsultationBlock.php b/lib/classes/JsonApi/Schemas/ConsultationBlock.php index 75a29df11b3..83ea3db3bd9 100644 --- a/lib/classes/JsonApi/Schemas/ConsultationBlock.php +++ b/lib/classes/JsonApi/Schemas/ConsultationBlock.php @@ -48,21 +48,15 @@ class ConsultationBlock extends SchemaProvider */ public function getRelationships($resource, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; - $relationships = []; - $relationships = $this->getSlotsRelationship($relationships, $resource, $shouldInclude(self::REL_SLOTS)); + $relationships = $this->getSlotsRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_SLOTS)); + $isPrimary = $context->getPosition()->getLevel() === 0; if (!$isPrimary) { return $relationships; } - $relationships = $this->getRangeRelationship($relationships, $resource, $shouldInclude(self::REL_RANGE)); + $relationships = $this->getRangeRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_RANGE)); return $relationships; } diff --git a/lib/classes/JsonApi/Schemas/ConsultationBooking.php b/lib/classes/JsonApi/Schemas/ConsultationBooking.php index 318f306f740..0368ac566ed 100644 --- a/lib/classes/JsonApi/Schemas/ConsultationBooking.php +++ b/lib/classes/JsonApi/Schemas/ConsultationBooking.php @@ -35,16 +35,9 @@ class ConsultationBooking extends SchemaProvider */ public function getRelationships($resource, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; - $relationships = []; - $relationships = $this->getSlotRelationship($relationships, $resource, $shouldInclude(self::REL_SLOT)); - $relationships = $this->getUserRelationship($relationships, $resource, $shouldInclude(self::REL_USER)); + $relationships = $this->getSlotRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_SLOT)); + $relationships = $this->getUserRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_USER)); return $relationships; } diff --git a/lib/classes/JsonApi/Schemas/ConsultationSlot.php b/lib/classes/JsonApi/Schemas/ConsultationSlot.php index 1adf912be57..a630bb6a42f 100644 --- a/lib/classes/JsonApi/Schemas/ConsultationSlot.php +++ b/lib/classes/JsonApi/Schemas/ConsultationSlot.php @@ -41,21 +41,15 @@ class ConsultationSlot extends SchemaProvider */ public function getRelationships($resource, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; - $relationships = []; - $relationships = $this->getBlockRelationship($relationships, $resource, $shouldInclude(self::REL_BLOCK)); + $relationships = $this->getBlockRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_BLOCK)); + $isPrimary = $context->getPosition()->getLevel() === 0; if (!$isPrimary) { return $relationships; } - $relationships = $this->getBookingsRelationship($relationships, $resource, $shouldInclude(self::REL_BOOKINGS)); + $relationships = $this->getBookingsRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_BOOKINGS)); return $relationships; } diff --git a/lib/classes/JsonApi/Schemas/Courseware/Container.php b/lib/classes/JsonApi/Schemas/Courseware/Container.php index ea6ab96957b..7842de2c7b3 100755 --- a/lib/classes/JsonApi/Schemas/Courseware/Container.php +++ b/lib/classes/JsonApi/Schemas/Courseware/Container.php @@ -47,16 +47,8 @@ class Container extends SchemaProvider */ public function getRelationships($resource, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - $relationships = []; - - $shouldInclude = function ($key) use ($includeList) { - return in_array($key, $includeList); - }; - - $relationships = $this->addBlocksRelationship($relationships, $resource, $shouldInclude(self::REL_BLOCKS)); + $relationships = $this->addBlocksRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_BLOCKS)); $relationships[self::REL_OWNER] = $resource['owner_id'] ? [ diff --git a/lib/classes/JsonApi/Schemas/Courseware/StructuralElement.php b/lib/classes/JsonApi/Schemas/Courseware/StructuralElement.php index ed3e32d423e..df8052b25fb 100755 --- a/lib/classes/JsonApi/Schemas/Courseware/StructuralElement.php +++ b/lib/classes/JsonApi/Schemas/Courseware/StructuralElement.php @@ -60,21 +60,13 @@ class StructuralElement extends SchemaProvider /** * {@inheritdoc} * - * @param \Courseware\Models\StructuralElement $resource - * @param bool $isPrimary - * @param array $includeList + * @param StructuralElement $resource + * @param ContextInterface $context */ public function getRelationships($resource, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - $relationships = []; - $shouldInclude = function ($key) use ($includeList) { - return in_array($key, $includeList); - }; - $relationships[self::REL_CHILDREN] = [ self::RELATIONSHIP_LINKS => [ Link::RELATED => $this->getRelationshipRelatedLink($resource, self::REL_CHILDREN), @@ -148,15 +140,20 @@ class StructuralElement extends SchemaProvider $relationships = $this->addAncestorsRelationship( $relationships, $resource, - $shouldInclude(self::REL_ANCESTORS) + $this->shouldInclude($context, self::REL_ANCESTORS) ); + $relationships = $this->addDescendantsRelationship( $relationships, $resource, - $shouldInclude(self::REL_DESCENDANTS) + $this->shouldInclude($context, self::REL_DESCENDANTS) ); - $relationships = $this->addImageRelationship($relationships, $resource, $shouldInclude(self::REL_IMAGE)); + $relationships = $this->addImageRelationship( + $relationships, + $resource, + $this->shouldInclude($context, self::REL_IMAGE) + ); return $relationships; } diff --git a/lib/classes/JsonApi/Schemas/FeedbackElement.php b/lib/classes/JsonApi/Schemas/FeedbackElement.php index 07096116872..143bb0c1cf4 100644 --- a/lib/classes/JsonApi/Schemas/FeedbackElement.php +++ b/lib/classes/JsonApi/Schemas/FeedbackElement.php @@ -66,19 +66,12 @@ class FeedbackElement extends SchemaProvider */ public function getRelationships($resource, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; - $relationships = []; - $relationships = $this->getAuthorRelationship($relationships, $resource, $shouldInclude(self::REL_AUTHOR)); - $relationships = $this->getCourseRelationship($relationships, $resource, $shouldInclude(self::REL_COURSE)); - $relationships = $this->getEntriesRelationship($relationships, $resource, $shouldInclude(self::REL_ENTRIES)); - $relationships = $this->getRangeRelationship($relationships, $resource, $shouldInclude(self::REL_RANGE)); + $relationships = $this->getAuthorRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_AUTHOR)); + $relationships = $this->getCourseRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_COURSE)); + $relationships = $this->getEntriesRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_ENTRIES)); + $relationships = $this->getRangeRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_RANGE)); return $relationships; } diff --git a/lib/classes/JsonApi/Schemas/FeedbackEntry.php b/lib/classes/JsonApi/Schemas/FeedbackEntry.php index e919c13f5fa..b84bf7709e4 100644 --- a/lib/classes/JsonApi/Schemas/FeedbackEntry.php +++ b/lib/classes/JsonApi/Schemas/FeedbackEntry.php @@ -36,20 +36,17 @@ class FeedbackEntry extends SchemaProvider */ public function getRelationships($resource, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; - $relationships = []; - $relationships = $this->getAuthorRelationship($relationships, $resource, $shouldInclude(self::REL_AUTHOR)); + $relationships = $this->getAuthorRelationship( + $relationships, + $resource, + $this->shouldInclude($context, self::REL_AUTHOR) + ); $relationships = $this->getFeedbackElementRelationship( $relationships, $resource, - $shouldInclude(self::REL_FEEDBACK) + $this->shouldInclude($context, self::REL_FEEDBACK) ); return $relationships; diff --git a/lib/classes/JsonApi/Schemas/Institute.php b/lib/classes/JsonApi/Schemas/Institute.php index 0ee99d95f8f..9d304ad8b50 100644 --- a/lib/classes/JsonApi/Schemas/Institute.php +++ b/lib/classes/JsonApi/Schemas/Institute.php @@ -38,15 +38,8 @@ class Institute extends SchemaProvider */ public function getRelationships($resource, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - $relationships = []; - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; - $filesLink = $this->getRelationshipRelatedLink($resource, self::REL_FILES); $relationships[self::REL_FILES] = [ self::RELATIONSHIP_LINKS => [ @@ -70,7 +63,7 @@ class Institute extends SchemaProvider $relationships = $this->addStatusGroupsRelationship( $relationships, $resource, - $shouldInclude(self::REL_STATUS_GROUPS) + $this->shouldInclude($context, self::REL_STATUS_GROUPS) ); return $relationships; diff --git a/lib/classes/JsonApi/Schemas/Message.php b/lib/classes/JsonApi/Schemas/Message.php index 211cf85405f..801c59ed18f 100644 --- a/lib/classes/JsonApi/Schemas/Message.php +++ b/lib/classes/JsonApi/Schemas/Message.php @@ -32,18 +32,11 @@ class Message extends SchemaProvider public function getRelationships($message, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; - $relationships = []; if ($isPrimary) { - $relationships = $this->getSenderRelationship($relationships, $message, $shouldInclude(self::REL_SENDER)); - $relationships = $this->getRecipientsRelationship($relationships, $message, $shouldInclude(self::REL_RECIPIENTS)); + $relationships = $this->getSenderRelationship($relationships, $message, $this->shouldInclude($context, self::REL_SENDER)); + $relationships = $this->getRecipientsRelationship($relationships, $message, $this->shouldInclude($context, self::REL_RECIPIENTS)); } return $relationships; diff --git a/lib/classes/JsonApi/Schemas/SchemaProvider.php b/lib/classes/JsonApi/Schemas/SchemaProvider.php index 5e158867ccb..c45c98168d2 100644 --- a/lib/classes/JsonApi/Schemas/SchemaProvider.php +++ b/lib/classes/JsonApi/Schemas/SchemaProvider.php @@ -4,6 +4,7 @@ namespace JsonApi\Schemas; use JsonApi\Errors\InternalServerError; use Neomerx\JsonApi\Contracts\Factories\FactoryInterface; +use Neomerx\JsonApi\Contracts\Schema\ContextInterface; use Neomerx\JsonApi\Contracts\Schema\LinkInterface; use Neomerx\JsonApi\Contracts\Schema\SchemaContainerInterface; use Neomerx\JsonApi\Schema\BaseSchema; @@ -58,4 +59,17 @@ abstract class SchemaProvider extends BaseSchema return $this->schemaContainer->getSchema($resource)->getSelfLink($resource); } + + /** + * @param ContextInterface $context + * @param string $key + * + * @return bool true, if the given relationship should be included in the response + */ + public function shouldInclude(ContextInterface $context, string $key): bool + { + $path = $context->getPosition()->getLevel() ? $context->getPosition()->getPath() . '.' : ''; + + return in_array($path . $key, $context->getIncludePaths()); + } } diff --git a/lib/classes/JsonApi/Schemas/SemClass.php b/lib/classes/JsonApi/Schemas/SemClass.php index 694d548e8d3..ea01a6377b8 100644 --- a/lib/classes/JsonApi/Schemas/SemClass.php +++ b/lib/classes/JsonApi/Schemas/SemClass.php @@ -33,20 +33,12 @@ class SemClass extends SchemaProvider public function getRelationships($resource, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - $relationships = []; - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; - - // SemTypes $relationships = $this->addSemTypesRelationship( $relationships, $resource, - $shouldInclude(self::REL_SEM_TYPES) + $this->shouldInclude($context, self::REL_SEM_TYPES) ); return $relationships; diff --git a/lib/classes/JsonApi/Schemas/StatusGroup.php b/lib/classes/JsonApi/Schemas/StatusGroup.php index 97993e10d5f..65f0830afd4 100644 --- a/lib/classes/JsonApi/Schemas/StatusGroup.php +++ b/lib/classes/JsonApi/Schemas/StatusGroup.php @@ -43,20 +43,12 @@ class StatusGroup extends SchemaProvider public function getRelationships($resource, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - $relationships = []; - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; - - // range-id $relationships = $this->addRangeRelationship( $relationships, $resource, - $shouldInclude(self::REL_RANGE) + $this->shouldInclude($context, self::REL_RANGE) ); return $relationships; diff --git a/lib/classes/JsonApi/Schemas/StudyArea.php b/lib/classes/JsonApi/Schemas/StudyArea.php index 6ad289bfc7e..f077d83b70b 100644 --- a/lib/classes/JsonApi/Schemas/StudyArea.php +++ b/lib/classes/JsonApi/Schemas/StudyArea.php @@ -30,19 +30,12 @@ class StudyArea extends SchemaProvider public function getRelationships($resource, ContextInterface $context): iterable { - $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - $relationships = []; - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; - - $relationships = $this->addChildrenRelationship($relationships, $resource, $shouldInclude(self::REL_CHILDREN)); - $relationships = $this->addCoursesRelationship($relationships, $resource, $shouldInclude(self::REL_COURSES)); - $relationships = $this->addInstituteRelationship($relationships, $resource, $shouldInclude(self::REL_INSTITUTE)); - $relationships = $this->addParentRelationship($relationships, $resource, $shouldInclude(self::REL_PARENT)); + $relationships = $this->addChildrenRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_CHILDREN)); + $relationships = $this->addCoursesRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_COURSES)); + $relationships = $this->addInstituteRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_INSTITUTE)); + $relationships = $this->addParentRelationship($relationships, $resource, $this->shouldInclude($context, self::REL_PARENT)); return $relationships; } diff --git a/lib/classes/JsonApi/Schemas/User.php b/lib/classes/JsonApi/Schemas/User.php index 67e64d56282..657f8f9c105 100644 --- a/lib/classes/JsonApi/Schemas/User.php +++ b/lib/classes/JsonApi/Schemas/User.php @@ -120,56 +120,51 @@ class User extends SchemaProvider public function getRelationships($user, ContextInterface $context): iterable { $isPrimary = $context->getPosition()->getLevel() === 0; - $includeList = $context->getIncludePaths(); - - $shouldInclude = function ($key) use ($isPrimary, $includeList) { - return $isPrimary && in_array($key, $includeList); - }; $relationships = []; if ($isPrimary) { $relationships = $this->getActivityStreamRelationship( $relationships, $user, - $shouldInclude(self::REL_ACTIVITYSTREAM) + $this->shouldInclude($context, self::REL_ACTIVITYSTREAM) ); $relationships = $this->getBlubberRelationship( $relationships, $user, - $shouldInclude(self::REL_BLUBBER) + $this->shouldInclude($context, self::REL_BLUBBER) ); $relationships = $this->getConfigValuesRelationship( $relationships, $user, - $shouldInclude(self::REL_CONFIG_VALUES) + $this->shouldInclude($context, self::REL_CONFIG_VALUES) ); $relationships = $this->getContactsRelationship( $relationships, $user, - $shouldInclude(self::REL_CONTACTS) + $this->shouldInclude($context, self::REL_CONTACTS) ); $relationships = $this->getCoursesRelationship( $relationships, $user, - $shouldInclude(self::REL_COURSES) + $this->shouldInclude($context, self::REL_COURSES) ); $relationships = $this->getCourseMembershipsRelationship( $relationships, $user, - $shouldInclude(self::REL_COURSE_MEMBERSHIPS) + $this->shouldInclude($context, self::REL_COURSE_MEMBERSHIPS) ); - $relationships = $this->getEventsRelationship($relationships, $user, $shouldInclude(self::REL_EVENTS)); - $relationships = $this->getFileRefsRelationship($relationships, $user, $shouldInclude(self::REL_FILES)); - $relationships = $this->getFoldersRelationship($relationships, $user, $shouldInclude(self::REL_FOLDERS)); - $relationships = $this->getInboxRelationship($relationships, $user, $shouldInclude(self::REL_INBOX)); + $relationships = $this->getEventsRelationship($relationships, $user, $this->shouldInclude($context, self::REL_EVENTS)); + $relationships = $this->getFileRefsRelationship($relationships, $user, $this->shouldInclude($context, self::REL_FILES)); + $relationships = $this->getFoldersRelationship($relationships, $user, $this->shouldInclude($context, self::REL_FOLDERS)); + $relationships = $this->getInboxRelationship($relationships, $user, $this->shouldInclude($context, self::REL_INBOX)); $relationships = $this->getInstituteMembershipsRelationship( $relationships, $user, - $shouldInclude(self::REL_INSTITUTE_MEMBERSHIPS) + $this->shouldInclude($context, self::REL_INSTITUTE_MEMBERSHIPS) ); - $relationships = $this->getNewsRelationship($relationships, $user, $shouldInclude(self::REL_NEWS)); - $relationships = $this->getOutboxRelationship($relationships, $user, $shouldInclude(self::REL_OUTBOX)); - $relationships = $this->getScheduleRelationship($relationships, $user, $shouldInclude(self::REL_SCHEDULE)); + $relationships = $this->getNewsRelationship($relationships, $user, $this->shouldInclude($context, self::REL_NEWS)); + $relationships = $this->getOutboxRelationship($relationships, $user, $this->shouldInclude($context, self::REL_OUTBOX)); + $relationships = $this->getScheduleRelationship($relationships, $user, $this->shouldInclude($context, self::REL_SCHEDULE)); } return $relationships; -- GitLab