"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.9/core/lib/Drupal/Core/Cache/Context/ProtocolVersionCacheContext.php" (18 Nov 2020, 855 Bytes) of package /linux/www/drupal-8.9.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ProtocolVersionCacheContext.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\Core\Cache\Context;
    4 
    5 use Drupal\Core\Cache\CacheableMetadata;
    6 
    7 /**
    8  * Defines the ProtocolVersionCacheContext service, for "per protocol" caching.
    9  *
   10  * Useful to differentiate between HTTP/1.1 and HTTP/2.0 responses for example,
   11  * to allow responses to be optimized for protocol-specific characteristics.
   12  *
   13  * Cache context ID: 'protocol_version'.
   14  */
   15 class ProtocolVersionCacheContext extends RequestStackCacheContextBase implements CacheContextInterface {
   16 
   17   /**
   18    * {@inheritdoc}
   19    */
   20   public static function getLabel() {
   21     return t('Protocol version');
   22   }
   23 
   24   /**
   25    * {@inheritdoc}
   26    */
   27   public function getContext() {
   28     return $this->requestStack->getCurrentRequest()->getProtocolVersion();
   29   }
   30 
   31   /**
   32    * {@inheritdoc}
   33    */
   34   public function getCacheableMetadata() {
   35     return new CacheableMetadata();
   36   }
   37 
   38 }