/** * {@inheritdoc} */ public function build(SetInterface $identities, ServerRequestInterface $request, HttpResource $definition, SpecificationInterface $specification = null, Range $range = null) : MapInterface { $map = new Map('string', HeaderInterface::class); if ($identities->size() === 0) { return $map; } $path = $request->url()->path(); return $map->put('Link', new Link($identities->reduce(new Set(HeaderValueInterface::class), function (Set $carry, IdentityInterface $identity) use($path) : Set { return $carry->add(new LinkValue(Url::fromString(rtrim((string) $path, '/') . '/' . $identity), 'resource', new Map('string', ParameterInterface::class))); }))); }
/** * {@inheritdoc} */ public function build(IdentityInterface $identity, ServerRequestInterface $request, HttpResource $definition, HttpResourceInterface $resource) : MapInterface { $map = new Map('string', HeaderInterface::class); return $map->put('Location', new Location(new LocationValue(Url::fromString(rtrim((string) $request->url()->path(), '/') . '/' . $identity)))); }