class IsMobileCacheContext in Mobile Detect 8.2
Defines the 'Is mobile' cache context.
Cache context ID: 'mobile_detect_is_mobile'.
Hierarchy
- class \Drupal\mobile_detect\Cache\Context\IsMobileCacheContext implements CacheContextInterface
Expanded class hierarchy of IsMobileCacheContext
1 string reference to 'IsMobileCacheContext'
1 service uses IsMobileCacheContext
File
- src/
Cache/ Context/ IsMobileCacheContext.php, line 14
Namespace
Drupal\mobile_detect\Cache\ContextView source
class IsMobileCacheContext implements CacheContextInterface {
/**
* @var \Detection\MobileDetect
*/
protected $mobileDetect;
/**
* Constructs an IsFrontPathCacheContext object.
*
* @param \Detection\MobileDetect $mobile_detect
*/
public function __construct(MobileDetect $mobile_detect) {
$this->mobileDetect = $mobile_detect;
}
/**
* {@inheritdoc}
*/
public static function getLabel() {
return 'Is mobile';
}
/**
* {@inheritdoc}
*/
public function getContext() {
return (string) $this->mobileDetect
->isMobile();
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata() {
return new CacheableMetadata();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
IsMobileCacheContext:: |
protected | property | ||
IsMobileCacheContext:: |
public | function |
Gets the cacheability metadata for the context. Overrides CacheContextInterface:: |
|
IsMobileCacheContext:: |
public | function |
Returns the string representation of the cache context. Overrides CacheContextInterface:: |
|
IsMobileCacheContext:: |
public static | function |
Returns the label of the cache context. Overrides CacheContextInterface:: |
|
IsMobileCacheContext:: |
public | function | Constructs an IsFrontPathCacheContext object. |