abstract class BackgroundImageBaseCacheContext in Background Image 8
Same name and namespace in other branches
- 2.x src/Cache/Context/BackgroundImageBaseCacheContext.php \Drupal\background_image\Cache\Context\BackgroundImageBaseCacheContext
- 2.0.x src/Cache/Context/BackgroundImageBaseCacheContext.php \Drupal\background_image\Cache\Context\BackgroundImageBaseCacheContext
Provides a base for Background Image based contexts.
Hierarchy
- class \Drupal\background_image\Cache\Context\BackgroundImageBaseCacheContext implements CacheContextInterface
Expanded class hierarchy of BackgroundImageBaseCacheContext
File
- src/
Cache/ Context/ BackgroundImageBaseCacheContext.php, line 12
Namespace
Drupal\background_image\Cache\ContextView source
abstract class BackgroundImageBaseCacheContext implements CacheContextInterface {
/**
* @var \Drupal\background_image\BackgroundImageManagerInterface
*/
protected $manager;
/**
* @var \Drupal\background_image\BackgroundImageInterface|null
*/
protected $backgroundImage;
/**
* Constructs a BackgroundImageCacheContext object.
*
* @param \Drupal\background_image\BackgroundImageManagerInterface $background_image_manager
*/
public function __construct(BackgroundImageManagerInterface $background_image_manager) {
$this->manager = $background_image_manager;
$this->backgroundImage = $background_image_manager
->getBackgroundImage();
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata() {
$metadata = new CacheableMetadata();
if ($this->backgroundImage) {
$metadata
->addCacheTags($this->backgroundImage
->getCacheTags());
}
return $metadata;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BackgroundImageBaseCacheContext:: |
protected | property | ||
BackgroundImageBaseCacheContext:: |
protected | property | ||
BackgroundImageBaseCacheContext:: |
public | function |
Gets the cacheability metadata for the context. Overrides CacheContextInterface:: |
|
BackgroundImageBaseCacheContext:: |
public | function | Constructs a BackgroundImageCacheContext object. | |
CacheContextInterface:: |
public | function | Returns the string representation of the cache context. | 23 |
CacheContextInterface:: |
public static | function | Returns the label of the cache context. | 23 |