comparison core/lib/Drupal/Core/EventSubscriber/CacheRouterRebuildSubscriber.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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 }