class RestMenuItemsCacheableDependency in Rest menu items 3.0.x
Same name and namespace in other branches
- 8.2 src/Plugin/rest/resource/RestMenuItemsCacheableDependency.php \Drupal\rest_menu_items\Plugin\rest\resource\RestMenuItemsCacheableDependency
Hierarchy
- class \Drupal\rest_menu_items\Plugin\rest\resource\RestMenuItemsCacheableDependency implements CacheableDependencyInterface
Expanded class hierarchy of RestMenuItemsCacheableDependency
File
- src/
Plugin/ rest/ resource/ RestMenuItemsCacheableDependency.php, line 8
Namespace
Drupal\rest_menu_items\Plugin\rest\resourceView source
class RestMenuItemsCacheableDependency implements CacheableDependencyInterface {
// Minimum depth parameter
protected $minDepth = 1;
// Maximum depth parameter
protected $maxDepth = 1;
// the menu being exposed
protected $menuName = '';
/**
* RestMenuItemsCachableDependency constructor.
*
* @param int $minDepth The minimum depth to be used as a cache context
* @param int $maxDepth The maximum depth to be used as a cache context
*/
public function __construct($menuName, $minDepth, $maxDepth) {
$this->menuName = $menuName;
$this->minDepth = $minDepth;
$this->maxDepth = $maxDepth;
}
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
$contexts = [];
// URL parameters as contexts
if ($this->minDepth != 1 || $this->maxDepth != 1) {
$contexts[] = 'url.query_args';
$contexts[] = 'user.permissions';
}
return $contexts;
}
/**
* {@inheritdoc}
*/
public function getCacheTags() {
$tags = [];
$tags[] = 'config:system.menu.' . $this->menuName;
return $tags;
}
/**
* {@inheritdoc}
*/
public function getCacheMaxAge() {
return Cache::PERMANENT;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RestMenuItemsCacheableDependency:: |
protected | property | ||
RestMenuItemsCacheableDependency:: |
protected | property | ||
RestMenuItemsCacheableDependency:: |
protected | property | ||
RestMenuItemsCacheableDependency:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyInterface:: |
|
RestMenuItemsCacheableDependency:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyInterface:: |
|
RestMenuItemsCacheableDependency:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyInterface:: |
|
RestMenuItemsCacheableDependency:: |
public | function | RestMenuItemsCachableDependency constructor. |