function CacheableSecuredRedirectResponse::fromResponse

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Routing/CacheableSecuredRedirectResponse.php \Drupal\Core\Routing\CacheableSecuredRedirectResponse::fromResponse()
  2. 10 core/lib/Drupal/Core/Routing/CacheableSecuredRedirectResponse.php \Drupal\Core\Routing\CacheableSecuredRedirectResponse::fromResponse()
  3. 11.x core/lib/Drupal/Core/Routing/CacheableSecuredRedirectResponse.php \Drupal\Core\Routing\CacheableSecuredRedirectResponse::fromResponse()

Overrides SecuredRedirectResponse::fromResponse

File

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

Class

CacheableSecuredRedirectResponse
Provides a common base class for cacheable safe redirects.

Namespace

Drupal\Core\Routing

Code

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

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