You are here

class PreviewLinkRerouteException in Preview Link 2.0.x

Same name and namespace in other branches
  1. 2.x src/Exception/PreviewLinkRerouteException.php \Drupal\preview_link\Exception\PreviewLinkRerouteException

Exception thrown when an entity needs to redirect to a preview link.

Hierarchy

Expanded class hierarchy of PreviewLinkRerouteException

2 files declare their use of PreviewLinkRerouteException
PreviewLinkCanonicalRerouteAccessCheck.php in src/Access/PreviewLinkCanonicalRerouteAccessCheck.php
PreviewLinkRouteEventSubscriber.php in src/EventSubscriber/PreviewLinkRouteEventSubscriber.php

File

src/Exception/PreviewLinkRerouteException.php, line 15

Namespace

Drupal\preview_link\Exception
View source
class PreviewLinkRerouteException extends \Exception implements CacheableDependencyInterface {
  use RefinableCacheableDependencyTrait;

  /**
   * The entity redirecting to preview link.
   *
   * @var \Drupal\Core\Entity\EntityInterface
   */
  protected $entity;

  /**
   * The preview link redirecting to.
   *
   * @var \Drupal\preview_link\Entity\PreviewLinkInterface
   */
  protected $previewLink;

  /**
   * PreviewLinkRerouteException constructor.
   *
   * @param string $message
   *   The Exception message to throw.
   * @param int $code
   *   The Exception code.
   * @param \Throwable|null $previous
   *   The previous throwable used for the exception chaining.
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity redirecting to preview link.
   * @param \Drupal\preview_link\Entity\PreviewLinkInterface $previewLink
   *   The preview link redirecting to.
   */
  public function __construct($message, $code, ?\Throwable $previous, EntityInterface $entity, PreviewLinkInterface $previewLink) {
    parent::__construct($message, $code, $previous);
    $this->entity = $entity;
    $this->previewLink = $previewLink;
  }

  /**
   * Get the entity redirecting to preview link.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   The entity redirecting to preview link.
   */
  public function getEntity() : EntityInterface {
    return clone $this->entity;
  }

  /**
   * Get the preview link redirecting to.
   *
   * @return \Drupal\preview_link\Entity\PreviewLinkInterface
   *   The preview link redirecting to.
   */
  public function getPreviewLink() : PreviewLinkInterface {
    return clone $this->previewLink;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::getCacheContexts public function 4
CacheableDependencyTrait::getCacheMaxAge public function 4
CacheableDependencyTrait::getCacheTags public function 4
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
PreviewLinkRerouteException::$entity protected property The entity redirecting to preview link.
PreviewLinkRerouteException::$previewLink protected property The preview link redirecting to.
PreviewLinkRerouteException::getEntity public function Get the entity redirecting to preview link.
PreviewLinkRerouteException::getPreviewLink public function Get the preview link redirecting to.
PreviewLinkRerouteException::__construct public function PreviewLinkRerouteException constructor.
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function