protected function LinkManagerBase::getLinkDomain in Drupal 8
Same name and namespace in other branches
- 9 core/modules/hal/src/LinkManager/LinkManagerBase.php \Drupal\hal\LinkManager\LinkManagerBase::getLinkDomain()
Gets the link domain.
Parameters
array $context: Normalization/serialization context.
Return value
string The link domain.
See also
\Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize()
\Symfony\Component\Serializer\SerializerInterface::serialize()
\Drupal\serialization\Normalizer\CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY
2 calls to LinkManagerBase::getLinkDomain()
- RelationLinkManager::getRelationUri in core/
modules/ hal/ src/ LinkManager/ RelationLinkManager.php - Gets the URI that corresponds to a field.
- TypeLinkManager::getTypeUri in core/
modules/ hal/ src/ LinkManager/ TypeLinkManager.php - Gets the URI that corresponds to a bundle.
File
- core/
modules/ hal/ src/ LinkManager/ LinkManagerBase.php, line 54
Class
- LinkManagerBase
- Defines an abstract base-class for HAL link manager objects.
Namespace
Drupal\hal\LinkManagerCode
protected function getLinkDomain(array $context = []) {
if (empty($this->linkDomain)) {
if ($domain = $this->configFactory
->get('hal.settings')
->get('link_domain')) {
// Bubble the appropriate cacheability metadata whenever possible.
if (isset($context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY])) {
$context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY]
->addCacheableDependency($this->configFactory
->get('hal.settings'));
}
return rtrim($domain, '/');
}
else {
// Bubble the relevant cacheability metadata whenever possible.
if (isset($context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY])) {
$context[CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY]
->addCacheContexts([
'url.site',
]);
}
$request = $this->requestStack
->getCurrentRequest();
return $request
->getSchemeAndHttpHost() . $request
->getBasePath();
}
}
return $this->linkDomain;
}