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.