Add support for layout builder block types

Created on 22 July 2022, over 2 years ago
Updated 1 March 2023, almost 2 years ago

Problem/Motivation

Currently both importer and exporter of layout_builder only supports InlineBlock:

ContentExporter.php:

          foreach ($components as $component) {
            if ($component->getPlugin() instanceof InlineBlock) {
              $configuration = $component->toArray()['configuration'];
              if (isset($configuration['block_revision_id'])) {
                $block = $block_storage->loadRevision($configuration['block_revision_id']);
                $block_list[] = $this->doExportToArray($block);
              }
            }
          }

ContentImporter.php

          foreach ($section_components as $component) {
            if ($component->getPlugin() instanceof InlineBlock) {
              $configuration = $component->toArray()['configuration'];
              if (isset($configuration['block_revision_id']) && isset($imported_blocks[$configuration['block_revision_id']])) {
                // Replace the old revision id with a new revision id.
                $configuration['block_revision_id'] = $imported_blocks[$configuration['block_revision_id']];
                $component->setConfiguration($configuration);
              }
            }
          }

Other block types, like blocks from custom library, fields or extra fields are silently skipped.

Steps to reproduce

1. Create a node with custom layout.
2. Add a block (such as View block).
3. Export the node.

Expected: the block is visible in exported YML.
Actual: the block is not in YML.

Proposed resolution

Either implement generic way of exporting blocks added to layout regardless of their type or implement plugin manager for different block types.

Remaining tasks

Implement + tests.

User interface changes

None.

API changes

New API for adding block types.

Data model changes

The YML file format would change but should remain backwards compatible.

✨ Feature request
Status

Closed: works as designed

Version

1.3

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

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