You are here

protected function LayoutBuilderDataHandlerTrait::serializeComponents in Acquia Content Hub 8.2

Prepares component to be serialized.

Parameters

\Drupal\layout_builder\SectionComponent[] $components: The component to add.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 call to LayoutBuilderDataHandlerTrait::serializeComponents()
LayoutBuilderDataHandlerTrait::serializeSections in src/LayoutBuilder/LayoutBuilderDataHandlerTrait.php
Prepares Layout Builder sections to be serialized.

File

src/LayoutBuilder/LayoutBuilderDataHandlerTrait.php, line 51

Class

LayoutBuilderDataHandlerTrait
Layout Builder trait for handling data.

Namespace

Drupal\acquia_contenthub\LayoutBuilder

Code

protected function serializeComponents(array $components) {
  foreach ($components as $component) {
    $plugin = $component
      ->getPlugin();

    // @todo Decide if it's worth to handle this as an event.
    if ($plugin instanceof InlineBlock) {
      $revision_id = $plugin
        ->getConfiguration()['block_revision_id'];
      $entity = $this->entityTypeManager
        ->getStorage('block_content')
        ->loadRevision($revision_id);
      $component
        ->set('block_uuid', $entity
        ->uuid());
    }
  }
}