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