You are here

abstract class CacheableSecuredRedirectResponse in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Routing/CacheableSecuredRedirectResponse.php \Drupal\Core\Routing\CacheableSecuredRedirectResponse

Provides a common base class for cacheable safe redirects.

Hierarchy

Expanded class hierarchy of CacheableSecuredRedirectResponse

File

core/lib/Drupal/Core/Routing/CacheableSecuredRedirectResponse.php, line 13

Namespace

Drupal\Core\Routing
View source
abstract class CacheableSecuredRedirectResponse extends SecuredRedirectResponse implements CacheableResponseInterface {
  use CacheableResponseTrait;

  /**
   * {@inheritdoc}
   */
  protected function fromResponse(RedirectResponse $response) {
    parent::fromResponse($response);
    $metadata = $this
      ->getCacheableMetadata();
    if ($response instanceof CacheableResponseInterface) {
      $metadata
        ->addCacheableDependency($response
        ->getCacheableMetadata());
    }
    else {
      $metadata
        ->setCacheMaxAge(0);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableResponseTrait::$cacheabilityMetadata protected property The cacheability metadata.
CacheableResponseTrait::addCacheableDependency public function
CacheableResponseTrait::getCacheableMetadata public function
CacheableSecuredRedirectResponse::fromResponse protected function Copies over the values from the given response. Overrides SecuredRedirectResponse::fromResponse
SecuredRedirectResponse::createFromRedirectResponse public static function Copies an existing redirect response into a safe one.
SecuredRedirectResponse::isSafe abstract protected function Returns whether the URL is considered as safe to redirect to. 2
SecuredRedirectResponse::setTargetUrl public function Sets the redirect target of this response.