Chris@0: linkDomain = rtrim($domain, '/'); Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets the link domain. Chris@0: * Chris@14: * @param array $context Chris@14: * Normalization/serialization context. Chris@14: * Chris@0: * @return string Chris@0: * The link domain. Chris@14: * Chris@14: * @see \Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize() Chris@14: * @see \Symfony\Component\Serializer\SerializerInterface::serialize() Chris@14: * @see \Drupal\serialization\Normalizer\CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY Chris@0: */ Chris@14: protected function getLinkDomain(array $context = []) { Chris@0: if (empty($this->linkDomain)) { Chris@0: if ($domain = $this->configFactory->get('hal.settings')->get('link_domain')) { Chris@14: // Bubble the appropriate cacheability metadata whenever possible. Chris@14: if (isset($context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY])) { Chris@14: $context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY]->addCacheableDependency($this->configFactory->get('hal.settings')); Chris@14: } Chris@14: return rtrim($domain, '/'); Chris@0: } Chris@0: else { Chris@14: // Bubble the relevant cacheability metadata whenever possible. Chris@14: if (isset($context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY])) { Chris@14: $context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY]->addCacheContexts(['url.site']); Chris@14: } Chris@0: $request = $this->requestStack->getCurrentRequest(); Chris@14: return $request->getSchemeAndHttpHost() . $request->getBasePath(); Chris@0: } Chris@0: } Chris@0: return $this->linkDomain; Chris@0: } Chris@0: Chris@0: }