function 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

6 calls to LinkManagerBase::getLinkDomain()
RelationLinkManager::getRelations in core/modules/hal/src/LinkManager/RelationLinkManager.php
Get the array of relation links.
RelationLinkManager::getRelationUri in core/modules/hal/src/LinkManager/RelationLinkManager.php
Gets the URI that corresponds to a field.
RelationLinkManager::writeCache in core/modules/hal/src/LinkManager/RelationLinkManager.php
Writes the cache of relation links.
TypeLinkManager::getTypes in core/modules/hal/src/LinkManager/TypeLinkManager.php
Get the array of type links.
TypeLinkManager::getTypeUri in core/modules/hal/src/LinkManager/TypeLinkManager.php
Gets the URI that corresponds to a bundle.

... See full list

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\LinkManager

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.