schemaContainer = $schemaContainer; $this->currentUser = $user; parent::__construct($factory); } const TYPE = ''; public function getType(): string { return static::TYPE; } /** * @inheritdoc */ public function isAddSelfLinkInRelationshipByDefault(string $relationshipName): bool { return false; } /** * @inheritdoc */ public function isAddRelatedLinkInRelationshipByDefault(string $relationshipName): bool { return false; } /** * @param mixed $resource */ public function createLinkToResource($resource): LinkInterface { if (!$this->schemaContainer->hasSchema($resource)) { throw new InternalServerError('Cannot create links to objects without schema.'); } 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()); } }