You are here

HighContrastCacheContext.php in High contrast 8

File

src/Cache/Context/HighContrastCacheContext.php
View source
<?php

namespace Drupal\high_contrast\Cache\Context;

use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Cache\Context\CacheContextInterface;
use Drupal\high_contrast\HighContrastTrait;

/**
 * Defines the HighContrastCacheContext service.
 *
 * This allows caching of high and normal contrast versions of pages.
 */
class HighContrastCacheContext implements CacheContextInterface {

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

  /**
   * {@inheritdoc}
   */
  public function getContext() {
    return HighContrastTrait::highContrastEnabled();
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata() {
    return new CacheableMetadata();
  }

}

Classes

Namesort descending Description
HighContrastCacheContext Defines the HighContrastCacheContext service.