You are here

class BackgroundImageSettingsTextCacheContext in Background Image 8

Same name and namespace in other branches
  1. 2.x src/Cache/Context/BackgroundImageSettingsTextCacheContext.php \Drupal\background_image\Cache\Context\BackgroundImageSettingsTextCacheContext
  2. 2.0.x src/Cache/Context/BackgroundImageSettingsTextCacheContext.php \Drupal\background_image\Cache\Context\BackgroundImageSettingsTextCacheContext

Cache context ID: 'background_image.settings.text'.

Hierarchy

Expanded class hierarchy of BackgroundImageSettingsTextCacheContext

1 string reference to 'BackgroundImageSettingsTextCacheContext'
background_image.services.yml in ./background_image.services.yml
background_image.services.yml
1 service uses BackgroundImageSettingsTextCacheContext
cache_context.background_image.settings.text in ./background_image.services.yml
Drupal\background_image\Cache\Context\BackgroundImageSettingsTextCacheContext

File

src/Cache/Context/BackgroundImageSettingsTextCacheContext.php, line 8

Namespace

Drupal\background_image\Cache\Context
View source
class BackgroundImageSettingsTextCacheContext extends BackgroundImageBaseCacheContext {

  /**
   * {@inheritdoc}
   */
  public static function getLabel() {
    return t('Background Image: Text Setting');
  }

  /**
   * {@inheritdoc}
   */
  public function getContext() {
    $context = $this->backgroundImage ? $this->backgroundImage
      ->getSettingsHash('text') : 0;

    // Add entity specific target if text has tokens.
    if ((!isset($name) || $name === 'text' || $name === 'text.value') && $this->backgroundImage
      ->hasEntityToken() && ($entity = $this->manager
      ->getEntityFromCurrentRoute())) {
      $context .= ":{$entity->getEntityTypeId()}:{$entity->id()}";
    }
    return $context;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BackgroundImageBaseCacheContext::$backgroundImage protected property
BackgroundImageBaseCacheContext::$manager protected property
BackgroundImageBaseCacheContext::getCacheableMetadata public function Gets the cacheability metadata for the context. Overrides CacheContextInterface::getCacheableMetadata
BackgroundImageBaseCacheContext::__construct public function Constructs a BackgroundImageCacheContext object.
BackgroundImageSettingsTextCacheContext::getContext public function Returns the string representation of the cache context. Overrides CacheContextInterface::getContext
BackgroundImageSettingsTextCacheContext::getLabel public static function Returns the label of the cache context. Overrides CacheContextInterface::getLabel