class RequestFormatCacheContext

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Cache/Context/RequestFormatCacheContext.php \Drupal\Core\Cache\Context\RequestFormatCacheContext
  2. 8.9.x core/lib/Drupal/Core/Cache/Context/RequestFormatCacheContext.php \Drupal\Core\Cache\Context\RequestFormatCacheContext
  3. 10 core/lib/Drupal/Core/Cache/Context/RequestFormatCacheContext.php \Drupal\Core\Cache\Context\RequestFormatCacheContext

Defines the RequestFormatCacheContext service, for "per format" caching.

Cache context ID: 'request_format'.

Hierarchy

Expanded class hierarchy of RequestFormatCacheContext

File

core/lib/Drupal/Core/Cache/Context/RequestFormatCacheContext.php, line 12

Namespace

Drupal\Core\Cache\Context
View source
class RequestFormatCacheContext extends RequestStackCacheContextBase {
    
    /**
     * {@inheritdoc}
     */
    public static function getLabel() {
        return t('Request format');
    }
    
    /**
     * {@inheritdoc}
     */
    public function getContext() {
        return $this->requestStack
            ->getCurrentRequest()
            ->getRequestFormat();
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCacheableMetadata() {
        return new CacheableMetadata();
    }

}

Members

Title Sort descending Modifiers Object type Summary
RequestFormatCacheContext::getCacheableMetadata public function
RequestFormatCacheContext::getContext public function
RequestFormatCacheContext::getLabel public static function
RequestStackCacheContextBase::$requestStack protected property The request stack.
RequestStackCacheContextBase::__construct public function Constructs a new RequestStackCacheContextBase class.

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