You are here

protected function InlineBlockEntityOperations::saveInlineBlockComponent in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/InlineBlockEntityOperations.php \Drupal\layout_builder\InlineBlockEntityOperations::saveInlineBlockComponent()

Saves an inline block component.

Parameters

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

\Drupal\layout_builder\SectionComponent $component: The section component with an inline block.

bool $new_revision: Whether a new revision of the block should be created when modified.

bool $duplicate_blocks: Whether the blocks should be duplicated.

1 call to InlineBlockEntityOperations::saveInlineBlockComponent()
InlineBlockEntityOperations::handlePreSave in core/modules/layout_builder/src/InlineBlockEntityOperations.php
Handles saving a parent entity.

File

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

Class

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

Namespace

Drupal\layout_builder

Code

protected function saveInlineBlockComponent(EntityInterface $entity, SectionComponent $component, $new_revision, $duplicate_blocks) {

  /** @var \Drupal\layout_builder\Plugin\Block\InlineBlock $plugin */
  $plugin = $component
    ->getPlugin();
  $pre_save_configuration = $plugin
    ->getConfiguration();
  $plugin
    ->saveBlockContent($new_revision, $duplicate_blocks);
  $post_save_configuration = $plugin
    ->getConfiguration();
  if ($duplicate_blocks || empty($pre_save_configuration['block_revision_id']) && !empty($post_save_configuration['block_revision_id'])) {
    $this->usage
      ->addUsage($this
      ->getPluginBlockId($plugin), $entity);
  }
  $component
    ->setConfiguration($post_save_configuration);
}