protected function LayoutBuilderInlineBlockStubCleanup::deleteDuplicatedBlockEntity in Acquia Content Hub 8.2
Looks for duplicate and deletes it.
Parameters
\Drupal\block_content\BlockContentInterface $block: Block content entity.
Throws
\Drupal\Core\Entity\EntityStorageException
1 call to LayoutBuilderInlineBlockStubCleanup::deleteDuplicatedBlockEntity()
- LayoutBuilderInlineBlockStubCleanup::onStubsCleanup in src/
EventSubscriber/ CleanupStubs/ LayoutBuilderInlineBlockStubCleanup.php - By default, we delete all stubs.
File
- src/
EventSubscriber/ CleanupStubs/ LayoutBuilderInlineBlockStubCleanup.php, line 114
Class
- LayoutBuilderInlineBlockStubCleanup
- Cleans up LB block stubs after import.
Namespace
Drupal\acquia_contenthub\EventSubscriber\CleanupStubsCode
protected function deleteDuplicatedBlockEntity(BlockContentInterface $block) {
// If the changed and info value is the same, then blocks are duplicates.
// Since this scenario is an edge case matching these should be enough.
$blocks = $this->entityTypeManager
->getStorage('block_content')
->loadByProperties([
'info' => $block
->get('info')->value,
'changed' => $block
->get('changed')->value,
]);
foreach ($blocks as $key => $entity) {
if ($key == $block
->id()) {
continue;
}
$entity
->delete();
}
}