protected function ParagraphsTypeIconUuidLookup::resolveCacheMiss in Paragraphs 8
Resolves a cache miss.
When an offset is not found in the object, this is treated as a cache miss. This method allows classes using this implementation to look up the actual value and allow it to be cached.
Parameters
string $key: The offset that was requested.
Return value
mixed The value of the offset, or NULL if no value was found.
Overrides CacheCollector::resolveCacheMiss
File
- src/
ParagraphsTypeIconUuidLookup.php, line 40
Class
- ParagraphsTypeIconUuidLookup
- A cache collector that caches IDs for the paragraphs_type entity icon UUIDs.
Namespace
Drupal\paragraphsCode
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;
}