RouteNameCacheContext.php

Same filename in other branches
  1. 9 core/lib/Drupal/Core/Cache/Context/RouteNameCacheContext.php
  2. 8.9.x core/lib/Drupal/Core/Cache/Context/RouteNameCacheContext.php
  3. 11.x core/lib/Drupal/Core/Cache/Context/RouteNameCacheContext.php

Namespace

Drupal\Core\Cache\Context

File

core/lib/Drupal/Core/Cache/Context/RouteNameCacheContext.php

View source
<?php

namespace Drupal\Core\Cache\Context;


/**
 * Defines the RouteCacheContext service, for "per route name" caching.
 *
 * Cache context ID: 'route.name'.
 */
class RouteNameCacheContext extends RouteCacheContext {
    
    /**
     * {@inheritdoc}
     */
    public static function getLabel() {
        return t('Route name');
    }
    
    /**
     * {@inheritdoc}
     */
    public function getContext() {
        return $this->routeMatch
            ->getRouteName();
    }

}

Classes

Title Deprecated Summary
RouteNameCacheContext Defines the RouteCacheContext service, for "per route name" caching.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.