3 namespace Drupal\Core\Routing;
5 use Drupal\Component\HttpFoundation\SecuredRedirectResponse;
6 use Drupal\Core\Cache\CacheableResponseInterface;
7 use Drupal\Core\Cache\CacheableResponseTrait;
8 use Symfony\Component\HttpFoundation\RedirectResponse;
11 * Provides a common base class for cacheable safe redirects.
13 abstract class CacheableSecuredRedirectResponse extends SecuredRedirectResponse implements CacheableResponseInterface {
15 use CacheableResponseTrait;
20 protected function fromResponse(RedirectResponse $response) {
21 parent::fromResponse($response);
23 $metadata = $this->getCacheableMetadata();
24 if ($response instanceof CacheableResponseInterface) {
25 $metadata->addCacheableDependency($response->getCacheableMetadata());
28 $metadata->setCacheMaxAge(0);