class RouteAdminCacheContext in Responsive Theme Preview 8
Defines the RouteCacheContext service for "per admin route" caching.
Cache context ID: 'route.is_admin'.
Hierarchy
- class \Drupal\responsive_preview\Cache\RouteAdminCacheContext implements CacheContextInterface
Expanded class hierarchy of RouteAdminCacheContext
1 string reference to 'RouteAdminCacheContext'
1 service uses RouteAdminCacheContext
File
- src/Cache/ RouteAdminCacheContext.php, line 14 
Namespace
Drupal\responsive_preview\CacheView source
class RouteAdminCacheContext implements CacheContextInterface {
  /**
   * The route admin context service.
   *
   * @var \Drupal\Core\Routing\AdminContext
   */
  protected $routeAdminContext;
  /**
   * Constructs a new RouteCacheContext class.
   *
   * @param \Drupal\Core\Routing\AdminContext $route_admin_context
   *   The route admin context service.
   */
  public function __construct(AdminContext $route_admin_context) {
    $this->routeAdminContext = $route_admin_context;
  }
  /**
   * {@inheritdoc}
   */
  public static function getLabel() {
    return t('Route is admin');
  }
  /**
   * {@inheritdoc}
   */
  public function getContext() {
    return $this->routeAdminContext
      ->isAdminRoute() ? '1' : '0';
  }
  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata() {
    return new CacheableMetadata();
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| RouteAdminCacheContext:: | protected | property | The route admin context service. | |
| RouteAdminCacheContext:: | public | function | Gets the cacheability metadata for the context. Overrides CacheContextInterface:: | |
| RouteAdminCacheContext:: | public | function | Returns the string representation of the cache context. Overrides CacheContextInterface:: | |
| RouteAdminCacheContext:: | public static | function | Returns the label of the cache context. Overrides CacheContextInterface:: | |
| RouteAdminCacheContext:: | public | function | Constructs a new RouteCacheContext class. | 
