class ParagraphsTypeIconUuidLookup in Paragraphs 8
A cache collector that caches IDs for the paragraphs_type entity icon UUIDs.
Hierarchy
- class \Drupal\Core\Cache\CacheCollector implements CacheCollectorInterface, DestructableInterface
- class \Drupal\paragraphs\ParagraphsTypeIconUuidLookup
Expanded class hierarchy of ParagraphsTypeIconUuidLookup
1 string reference to 'ParagraphsTypeIconUuidLookup'
1 service uses ParagraphsTypeIconUuidLookup
File
- src/
ParagraphsTypeIconUuidLookup.php, line 13
Namespace
Drupal\paragraphsView source
class ParagraphsTypeIconUuidLookup extends CacheCollector {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a ParagraphsTypeIconUuidLookup instance.
*
* @param \Drupal\Core\Cache\CacheBackendInterface $cache
* The cache backend.
* @param \Drupal\Core\Lock\LockBackendInterface $lock
* The lock backend.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(CacheBackendInterface $cache, LockBackendInterface $lock, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct('paragraphs_type_icon_uuid', $cache, $lock);
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
protected function resolveCacheMiss($key) {
$ids = $this->entityTypeManager
->getStorage('file')
->getQuery()
->condition('uuid', $key)
->execute();
// Only cache if there is a match, otherwise creating new entities would
// require to invalidate the cache.
$id = reset($ids);
if ($id) {
$this->storage[$key] = $id;
$this
->persist($key);
}
return $id;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheCollector:: |
protected | property | The cache backend that should be used. | 1 |
CacheCollector:: |
protected | property | Stores the cache creation time. | |
CacheCollector:: |
protected | property | Flag that indicates of the cache has been invalidated. | |
CacheCollector:: |
protected | property | Indicates if the collected cache was already loaded. | |
CacheCollector:: |
protected | property | The cache id that is used for the cache entry. | |
CacheCollector:: |
protected | property | An array of keys to add to the cache on service termination. | |
CacheCollector:: |
protected | property | An array of keys to remove from the cache on service termination. | |
CacheCollector:: |
protected | property | The lock backend that should be used. | 1 |
CacheCollector:: |
protected | property | Storage for the data itself. | |
CacheCollector:: |
protected | property | A list of tags that are used for the cache entry. | |
CacheCollector:: |
public | function |
Clears the collected cache entry. Overrides CacheCollectorInterface:: |
1 |
CacheCollector:: |
public | function |
Deletes the element. Overrides CacheCollectorInterface:: |
|
CacheCollector:: |
public | function |
Performs destruct operations. Overrides DestructableInterface:: |
|
CacheCollector:: |
public | function |
Gets value from the cache. Overrides CacheCollectorInterface:: |
2 |
CacheCollector:: |
protected | function | Gets the cache ID. | 3 |
CacheCollector:: |
public | function |
Returns whether data exists for this key. Overrides CacheCollectorInterface:: |
1 |
CacheCollector:: |
protected | function | Invalidate the cache. | |
CacheCollector:: |
protected | function | Loads the cache if not already done. | 1 |
CacheCollector:: |
protected | function | Normalizes a cache ID in order to comply with database limitations. | |
CacheCollector:: |
protected | function | Flags an offset value to be written to the persistent cache. | |
CacheCollector:: |
public | function |
Resets the local cache. Overrides CacheCollectorInterface:: |
1 |
CacheCollector:: |
public | function |
Implements \Drupal\Core\Cache\CacheCollectorInterface::set(). Overrides CacheCollectorInterface:: |
1 |
CacheCollector:: |
protected | function | Writes a value to the persistent cache immediately. | 1 |
ParagraphsTypeIconUuidLookup:: |
protected | property | The entity type manager. | |
ParagraphsTypeIconUuidLookup:: |
protected | function |
Resolves a cache miss. Overrides CacheCollector:: |
|
ParagraphsTypeIconUuidLookup:: |
public | function |
Constructs a ParagraphsTypeIconUuidLookup instance. Overrides CacheCollector:: |