RouteNameCacheContext.php 439 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace Drupal\Core\Cache\Context;
  3. /**
  4. * Defines the RouteCacheContext service, for "per route name" caching.
  5. *
  6. * Cache context ID: 'route.name'.
  7. */
  8. class RouteNameCacheContext extends RouteCacheContext {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public static function getLabel() {
  13. return t('Route name');
  14. }
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public function getContext() {
  19. return $this->routeMatch->getRouteName();
  20. }
  21. }