Mercurial > hg > isophonics-drupal-site
annotate core/lib/Drupal/Core/EventSubscriber/CacheRouterRebuildSubscriber.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\Core\EventSubscriber; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Core\Cache\Cache; |
Chris@0 | 6 use Drupal\Core\Routing\RoutingEvents; |
Chris@0 | 7 use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
Chris@0 | 8 |
Chris@0 | 9 /** |
Chris@0 | 10 * Clear cache tags when the router is rebuilt. |
Chris@0 | 11 */ |
Chris@0 | 12 class CacheRouterRebuildSubscriber implements EventSubscriberInterface { |
Chris@0 | 13 |
Chris@0 | 14 /** |
Chris@0 | 15 * {@inheritdoc} |
Chris@0 | 16 */ |
Chris@0 | 17 public function onRouterFinished() { |
Chris@0 | 18 // Requested URLs that formerly gave a 403/404 may now be valid. |
Chris@0 | 19 // Also invalidate all cached routing as well as every HTTP response. |
Chris@0 | 20 Cache::invalidateTags(['4xx-response', 'route_match', 'http_response']); |
Chris@0 | 21 } |
Chris@0 | 22 |
Chris@0 | 23 /** |
Chris@0 | 24 * {@inheritdoc} |
Chris@0 | 25 */ |
Chris@0 | 26 public static function getSubscribedEvents() { |
Chris@0 | 27 $events = []; |
Chris@0 | 28 // Act only when the router rebuild is finished. |
Chris@0 | 29 $events[RoutingEvents::FINISHED][] = ['onRouterFinished', 200]; |
Chris@0 | 30 return $events; |
Chris@0 | 31 } |
Chris@0 | 32 |
Chris@0 | 33 } |