class HandyCacheTagsManager in Handy cache tags 8
HandyCacheTagsManager service.
Hierarchy
- class \Drupal\handy_cache_tags\HandyCacheTagsManager
Expanded class hierarchy of HandyCacheTagsManager
2 files declare their use of HandyCacheTagsManager
- HandyCacheTagsBase.php in tests/
src/ Unit/ HandyCacheTagsBase.php - TagNamesTest.php in tests/
src/ Unit/ TagNamesTest.php
1 string reference to 'HandyCacheTagsManager'
1 service uses HandyCacheTagsManager
File
- src/
HandyCacheTagsManager.php, line 10
Namespace
Drupal\handy_cache_tagsView source
class HandyCacheTagsManager {
/**
* The cache prefix we use for all cache tags.
*/
const CACHE_PREFIX = 'handy_cache_tags';
/**
* Creates cache tags from entities.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* An entity to use.
*
* @return array
* Array of cache tags.
*/
public function getEntityTags(EntityInterface $entity) {
return [
$this
->getEntityTypeTagFromEntity($entity),
$this
->getBundleTagFromEntity($entity),
];
}
/**
* Gets entity type tags from the entity.
*/
public function getEntityTypeTagFromEntity(EntityInterface $entity) {
return $this
->getTag($entity
->getEntityTypeId());
}
/**
* Gets a tag from a string.
*/
public function getTag($type) {
return sprintf('%s:%s', $this::CACHE_PREFIX, $type);
}
/**
* Gets bundle tag for an entity.
*/
public function getBundleTagFromEntity(EntityInterface $entity) {
return $this
->getBundleTag($entity
->getEntityTypeId(), $entity
->bundle());
}
/**
* Gets a bundle tag from a type and a bundle.
*/
public function getBundleTag($entity_type, $bundle) {
return $this
->getTag(sprintf('%s:%s', $entity_type, $bundle));
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HandyCacheTagsManager:: |
constant | The cache prefix we use for all cache tags. | ||
HandyCacheTagsManager:: |
public | function | Gets a bundle tag from a type and a bundle. | |
HandyCacheTagsManager:: |
public | function | Gets bundle tag for an entity. | |
HandyCacheTagsManager:: |
public | function | Creates cache tags from entities. | |
HandyCacheTagsManager:: |
public | function | Gets entity type tags from the entity. | |
HandyCacheTagsManager:: |
public | function | Gets a tag from a string. |