class RequestFormatCacheContext

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Cache/Context/RequestFormatCacheContext.php \Drupal\Core\Cache\Context\RequestFormatCacheContext
  2. 10 core/lib/Drupal/Core/Cache/Context/RequestFormatCacheContext.php \Drupal\Core\Cache\Context\RequestFormatCacheContext
  3. 11.x 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

1 string reference to 'RequestFormatCacheContext'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses RequestFormatCacheContext
cache_context.request_format in core/core.services.yml
Drupal\Core\Cache\Context\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.