diff --git a/lib/classes/JsonApi/Schemas/Activity.php b/lib/classes/JsonApi/Schemas/Activity.php index ae95e0c0ea5e671882e96a4470e0401ffcdc24e2..607b41d011be356875f1da0b818b98db06e08a26 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 2aabd5e19ea9e80322f9d5a32054d2c2727b6246..00770237b02f9bcf138c2df389897eb222ca4cfd 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 386b51e1cd1ba406502d6b447cf153cbd99f181c..2a7f6605587b1c9512ab7b0cd0e551a43730f169 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 75a29df11b38fdc7f98693a63672ea31aa3b8fa5..83ea3db3bd9504c126d5580baa484949dd690328 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 318f306f74039e33dc0d8f3f2b33634c834239ef..0368ac566edba7a79e4ee838107b6429ddeb7797 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 1adf912be57de1458faba0a92356e11988a8e934..a630bb6a42f98e8665d944b6d1debf2816003c22 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 ea6ab96957bc6ce6ba6b43ba83a891826175cb6b..7842de2c7b3d8e8e277bced2190ee76dd23fc555 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 ed3e32d423e01ccb3983d6d6d1abf07666db1198..df8052b25fb5be0035e8eb27c9d42a27426a3677 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 0709611687203ddb5be9d25a6a9c9aa2de276bf2..143bb0c1cf47776d38da16e3d6a4a0f26ebf28e3 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 e919c13f5fa02a32d76571a839437323bde5b43b..b84bf7709e444f7f0acd7dc857c9e26d1794628b 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 0ee99d95f8fb719e235b2ae5e4a46b937be1e97f..9d304ad8b5075cd22d360b91bf0ad0623cc7aa6f 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 211cf85405f93bd11c92fac399d0acffadd1a97d..801c59ed18f17bb3b6f5ff35d8ce2b45b01f69b8 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 5e158867ccb2e6996e65505dd8b453a668314a21..c45c98168d23a859307b09fa58d20d19832555cb 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 694d548e8d35dc2d340434f1e4ad8929d06d604c..ea01a6377b8f1d0b03c33af9a6bc0a2283018693 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 97993e10d5f442448c1b8414c693b287edbc72cf..65f0830afd47a60c4b54db512b7be0293dc9d67a 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 6ad289bfc7e8933543e97a96107d22eaa10f5a6a..f077d83b70bf888c2a680bbfe232529c0995c3ef 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 67e64d56282f8c4a6e867ba1d6b4e6c40bb87fc3..657f8f9c10594753135943d08cadacaf9221af44 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;