Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. InlineBlockEntityOperations.php

function InlineBlockEntityOperations::getRemovedBlockIds

Gets the IDs of the inline blocks that were removed.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The layout entity.

Return value

int[] The block content IDs that were removed.

1 call to InlineBlockEntityOperations::getRemovedBlockIds()
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 112

Class

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

Namespace

Drupal\layout_builder

Code

protected function getRemovedBlockIds(EntityInterface $entity) {
    $original_sections = $this->getEntitySections($entity->original);
    $current_sections = $this->getEntitySections($entity);
    // Avoid un-needed conversion from revision IDs to block content IDs by
    // first determining if there are any revisions in the original that are not
    // also in the current sections.
    $current_block_content_revision_ids = $this->getInlineBlockRevisionIdsInSections($current_sections);
    $original_block_content_revision_ids = $this->getInlineBlockRevisionIdsInSections($original_sections);
    if ($unused_original_revision_ids = array_diff($original_block_content_revision_ids, $current_block_content_revision_ids)) {
        // If there are any revisions in the original that aren't in the current
        // there may some blocks that need to be removed.
        $current_block_content_ids = $this->getBlockIdsForRevisionIds($current_block_content_revision_ids);
        $unused_original_block_content_ids = $this->getBlockIdsForRevisionIds($unused_original_revision_ids);
        return array_diff($unused_original_block_content_ids, $current_block_content_ids);
    }
    return [];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal