You are here

abstract class LinkManagerBase in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/rest/src/LinkManager/LinkManagerBase.php \Drupal\rest\LinkManager\LinkManagerBase

Defines an abstract base-class for REST link manager objects.

Hierarchy

Expanded class hierarchy of LinkManagerBase

File

core/modules/rest/src/LinkManager/LinkManagerBase.php, line 13
Contains \Drupal\rest\LinkManager\LinkManagerBase.

Namespace

Drupal\rest\LinkManager
View source
abstract class LinkManagerBase {

  /**
   * Link domain used for type links URIs.
   *
   * @var string
   */
  protected $linkDomain;

  /**
   * Config factory service.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * The request stack.
   *
   * @var \Symfony\Component\HttpFoundation\RequestStack
   */
  protected $requestStack;

  /**
   * {@inheritdoc}
   */
  public function setLinkDomain($domain) {
    $this->linkDomain = rtrim($domain, '/');
    return $this;
  }

  /**
   * Gets the link domain.
   *
   * @return string
   *   The link domain.
   */
  protected function getLinkDomain() {
    if (empty($this->linkDomain)) {
      if ($domain = $this->configFactory
        ->get('rest.settings')
        ->get('link_domain')) {
        $this->linkDomain = rtrim($domain, '/');
      }
      else {
        $request = $this->requestStack
          ->getCurrentRequest();
        $this->linkDomain = $request
          ->getSchemeAndHttpHost() . $request
          ->getBasePath();
      }
    }
    return $this->linkDomain;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LinkManagerBase::$configFactory protected property Config factory service.
LinkManagerBase::$linkDomain protected property Link domain used for type links URIs.
LinkManagerBase::$requestStack protected property The request stack.
LinkManagerBase::getLinkDomain protected function Gets the link domain.
LinkManagerBase::setLinkDomain public function