HandyCacheTagsManager.php in Handy cache tags 8
File
src/HandyCacheTagsManager.php
View source
<?php
namespace Drupal\handy_cache_tags;
use Drupal\Core\Entity\EntityInterface;
class HandyCacheTagsManager {
const CACHE_PREFIX = 'handy_cache_tags';
public function getEntityTags(EntityInterface $entity) {
return [
$this
->getEntityTypeTagFromEntity($entity),
$this
->getBundleTagFromEntity($entity),
];
}
public function getEntityTypeTagFromEntity(EntityInterface $entity) {
return $this
->getTag($entity
->getEntityTypeId());
}
public function getTag($type) {
return sprintf('%s:%s', $this::CACHE_PREFIX, $type);
}
public function getBundleTagFromEntity(EntityInterface $entity) {
return $this
->getBundleTag($entity
->getEntityTypeId(), $entity
->bundle());
}
public function getBundleTag($entity_type, $bundle) {
return $this
->getTag(sprintf('%s:%s', $entity_type, $bundle));
}
}