X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fblock_content%2Fsrc%2FBlockContentUuidLookup.php;fp=web%2Fcore%2Fmodules%2Fblock_content%2Fsrc%2FBlockContentUuidLookup.php;h=d771d98eacd0477b35dd43ac06b9099fd06867e6;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=0000000000000000000000000000000000000000;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/web/core/modules/block_content/src/BlockContentUuidLookup.php b/web/core/modules/block_content/src/BlockContentUuidLookup.php new file mode 100644 index 000000000..d771d98ea --- /dev/null +++ b/web/core/modules/block_content/src/BlockContentUuidLookup.php @@ -0,0 +1,63 @@ +entityTypeManager = $entity_type_manager; + } + + /** + * {@inheritdoc} + */ + protected function resolveCacheMiss($key) { + $ids = $this->entityTypeManager->getStorage('block_content')->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; + } + +}