You are here

class RouteNameCacheContext in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Cache/Context/RouteNameCacheContext.php \Drupal\Core\Cache\Context\RouteNameCacheContext
  2. 9 core/lib/Drupal/Core/Cache/Context/RouteNameCacheContext.php \Drupal\Core\Cache\Context\RouteNameCacheContext

Defines the RouteCacheContext service, for "per route name" caching.

Cache context ID: 'route.name'.

Hierarchy

Expanded class hierarchy of RouteNameCacheContext

1 file declares its use of RouteNameCacheContext
LayoutBuilderUiCacheContext.php in core/modules/layout_builder/src/Cache/LayoutBuilderUiCacheContext.php
1 string reference to 'RouteNameCacheContext'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses RouteNameCacheContext
cache_context.route.name in core/core.services.yml
Drupal\Core\Cache\Context\RouteNameCacheContext

File

core/lib/Drupal/Core/Cache/Context/RouteNameCacheContext.php, line 10

Namespace

Drupal\Core\Cache\Context
View source
class RouteNameCacheContext extends RouteCacheContext {

  /**
   * {@inheritdoc}
   */
  public static function getLabel() {
    return t('Route name');
  }

  /**
   * {@inheritdoc}
   */
  public function getContext() {
    return $this->routeMatch
      ->getRouteName();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouteCacheContext::$routeMatch protected property The route match.
RouteCacheContext::getCacheableMetadata public function Gets the cacheability metadata for the context. Overrides CacheContextInterface::getCacheableMetadata
RouteCacheContext::__construct public function Constructs a new RouteCacheContext class.
RouteNameCacheContext::getContext public function Returns the string representation of the cache context. Overrides RouteCacheContext::getContext 1
RouteNameCacheContext::getLabel public static function Returns the label of the cache context. Overrides RouteCacheContext::getLabel 1