Security update for Core, with self-updated composer
[yaffs-website] / web / core / lib / Drupal / Core / EventSubscriber / CacheRouterRebuildSubscriber.php
1 <?php
2
3 namespace Drupal\Core\EventSubscriber;
4
5 use Drupal\Core\Cache\Cache;
6 use Drupal\Core\Routing\RoutingEvents;
7 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
9 /**
10  * Clear cache tags when the router is rebuilt.
11  */
12 class CacheRouterRebuildSubscriber implements EventSubscriberInterface {
13
14   /**
15    * {@inheritdoc}
16    */
17   public function onRouterFinished() {
18     // Requested URLs that formerly gave a 403/404 may now be valid.
19     // Also invalidate all cached routing as well as every HTTP response.
20     Cache::invalidateTags(['4xx-response', 'route_match', 'http_response']);
21   }
22
23   /**
24    * {@inheritdoc}
25    */
26   public static function getSubscribedEvents() {
27     $events = [];
28     // Act only when the router rebuild is finished.
29     $events[RoutingEvents::FINISHED][] = ['onRouterFinished', 200];
30     return $events;
31   }
32
33 }