Upgraded drupal core with security updates
[yaffs-website] / web / core / lib / Drupal / Core / Routing / CacheableSecuredRedirectResponse.php
1 <?php
2
3 namespace Drupal\Core\Routing;
4
5 use Drupal\Component\HttpFoundation\SecuredRedirectResponse;
6 use Drupal\Core\Cache\CacheableResponseInterface;
7 use Drupal\Core\Cache\CacheableResponseTrait;
8 use Symfony\Component\HttpFoundation\RedirectResponse;
9
10 /**
11  * Provides a common base class for cacheable safe redirects.
12  */
13 abstract class CacheableSecuredRedirectResponse extends SecuredRedirectResponse implements CacheableResponseInterface {
14
15   use CacheableResponseTrait;
16
17   /**
18    * {@inheritdoc}
19    */
20   protected function fromResponse(RedirectResponse $response) {
21     parent::fromResponse($response);
22
23     $metadata = $this->getCacheableMetadata();
24     if ($response instanceof CacheableResponseInterface) {
25       $metadata->addCacheableDependency($response->getCacheableMetadata());
26     }
27     else {
28       $metadata->setCacheMaxAge(0);
29     }
30   }
31
32 }