function InlineBlockEntityOperations::deleteBlocksAndUsage

Same name in other branches
  1. 9 core/modules/layout_builder/src/InlineBlockEntityOperations.php \Drupal\layout_builder\InlineBlockEntityOperations::deleteBlocksAndUsage()
  2. 8.9.x core/modules/layout_builder/src/InlineBlockEntityOperations.php \Drupal\layout_builder\InlineBlockEntityOperations::deleteBlocksAndUsage()
  3. 11.x core/modules/layout_builder/src/InlineBlockEntityOperations.php \Drupal\layout_builder\InlineBlockEntityOperations::deleteBlocksAndUsage()

Delete the inline blocks and the usage records.

Parameters

int[] $block_content_ids: The block content entity IDs.

2 calls to InlineBlockEntityOperations::deleteBlocksAndUsage()
InlineBlockEntityOperations::removeUnused in core/modules/layout_builder/src/InlineBlockEntityOperations.php
Removes unused inline blocks.
InlineBlockEntityOperations::removeUnusedForEntityOnSave in core/modules/layout_builder/src/InlineBlockEntityOperations.php
Remove all unused inline blocks on save.

File

core/modules/layout_builder/src/InlineBlockEntityOperations.php, line 179

Class

InlineBlockEntityOperations
Defines a class for reacting to entity events related to Inline Blocks.

Namespace

Drupal\layout_builder

Code

protected function deleteBlocksAndUsage(array $block_content_ids) {
    foreach ($block_content_ids as $block_content_id) {
        if ($block = $this->blockContentStorage
            ->load($block_content_id)) {
            $block->delete();
        }
    }
    $this->usage
        ->deleteUsage($block_content_ids);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.