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

Breadcrumb

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

function InlineBlockEntityOperations::handlePreSave

Handles saving a parent entity.

Parameters

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

File

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

Class

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

Namespace

Drupal\layout_builder

Code

public function handlePreSave(EntityInterface $entity) {
    if ($entity instanceof SynchronizableInterface && $entity->isSyncing() || !$this->isLayoutCompatibleEntity($entity)) {
        return;
    }
    $duplicate_blocks = FALSE;
    if ($sections = $this->getEntitySections($entity)) {
        if ($this->originalEntityUsesDefaultStorage($entity)) {
            // This is a new override from a default and the blocks need to be
            // duplicated.
            $duplicate_blocks = TRUE;
        }
        // Since multiple parent entity revisions may reference common block
        // revisions, when a block is modified, it must always result in the
        // creation of a new block revision.
        $new_revision = $entity instanceof RevisionableInterface;
        foreach ($this->getInlineBlockComponents($sections) as $component) {
            $this->saveInlineBlockComponent($entity, $component, $new_revision, $duplicate_blocks);
        }
    }
    $this->removeUnusedForEntityOnSave($entity);
}

API Navigation

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