protected function AcsfDuplicationScrubCommentStorage::invokeStorageLoadHook in Acquia Cloud Site Factory Connector 8
Same name and namespace in other branches
- 8.2 src/Event/AcsfDuplicationScrubCommentStorage.php \Drupal\acsf\Event\AcsfDuplicationScrubCommentStorage::invokeStorageLoadHook()
Invokes hook_entity_storage_load() while catching exceptions thrown.
Unlike SqlContentEntityStorage's implementation, this prevents a hook_comment_storage_load() implementation somewhere in contrib from throwing exceptions while loading orphaned comments, and causing Wip failures.
Issue https://www.drupal.org/node/2614720 was filed and this method was written assuming that Drupal Core itself was throwing exceptions which should be caught, while loading orphaned comments. Unfortunately that's not the case: RDF module throws a fatal error (not an exception). So now this method does not solve a known problem; it's just a semi random extra precaution in case a contrib module does funny things. This may be deleted if we value minimizing code over supporting random theoretical failures.
Parameters
\Drupal\Core\Entity\ContentEntityInterface[] $entities: List of entities, keyed on the entity ID.
Overrides ContentEntityStorageBase::invokeStorageLoadHook
File
- src/
Event/ AcsfDuplicationScrubCommentStorage.php, line 35
Class
- AcsfDuplicationScrubCommentStorage
- Comment storage class (using a SQL backend) which ignores load failures.
Namespace
Drupal\acsf\EventCode
protected function invokeStorageLoadHook(array &$entities) {
if (!empty($entities)) {
// Call hook_entity_storage_load().
foreach ($this
->moduleHandler()
->getImplementations('entity_storage_load') as $module) {
$function = $module . '_entity_storage_load';
try {
$function($entities, $this->entityTypeId);
} catch (\Exception $e) {
// Don't care.
}
}
// Call hook_TYPE_storage_load().
foreach ($this
->moduleHandler()
->getImplementations($this->entityTypeId . '_storage_load') as $module) {
$function = $module . '_' . $this->entityTypeId . '_storage_load';
try {
$function($entities);
} catch (\Exception $e) {
// Don't care.
}
}
}
}