Allow inline blocks to be duplicated when you clone a SectionComponent

Created on 10 April 2019, over 5 years ago
Updated 10 April 2024, 5 months ago

Problem/Motivation

Currently a inline block plugin is only duplicated if the parameter $duplicate_block is set to TRUE in the ::saveBlockContent method.

To currently clone a section component that holds a inline block plugin you must do something like:

    // Handle inline blocks.
    foreach ($duplicated_section->getComponents() as $component) {
      $plugin = $component->getPlugin();
      if ($plugin instanceof DerivativeInspectionInterface && $plugin->getBaseId() === 'inline_block') {

        $configuration = $plugin->getConfiguration();

        if (!empty($configuration['block_revision_id'])) {

          $block = \Drupal::entityTypeManager()->getStorage('block_content')->loadRevision($configuration['block_revision_id']);

          $duplicated_block = $block->createDuplicate();

          $configuration['block_serialized'] = serialize($duplicated_block);
          $configuration['block_revision_id'] = NULL;

          $component->setConfiguration($configuration);

        }

      }

Can we simplify this behaviour?

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component
Layout builderΒ  β†’

Last updated less than a minute ago

Created by

πŸ‡ΈπŸ‡ͺSweden johnwebdev

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024