You are here

public function EntityViewDisplaySerializer::onSerializeConfigEntity in Acquia Content Hub 8.2

Serializes layout_builder 3rd party settings data on entity_view_displays.

Parameters

\Drupal\acquia_contenthub\Event\ConfigDataEvent $event: The config data event object.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

File

src/EventSubscriber/SerializeConfig/EntityViewDisplaySerializer.php, line 47

Class

EntityViewDisplaySerializer
Serializer for entity view displays.

Namespace

Drupal\acquia_contenthub\EventSubscriber\SerializeConfig

Code

public function onSerializeConfigEntity(ConfigDataEvent $event) {

  /** @var \Drupal\Core\Entity\Entity\EntityViewDisplay $entity */
  $entity = $event
    ->getEntity();
  if ($entity
    ->getEntityTypeId() !== 'entity_view_display') {
    return;
  }
  $sections = $entity
    ->getThirdPartySetting('layout_builder', 'sections') ?? [];
  if ($sections) {
    $data = $event
      ->getData();
    $data[$entity
      ->language()
      ->getId()]['third_party_settings']['layout_builder']['sections'] = $this
      ->serializeSections(...$sections);
    $event
      ->setData($data);
  }
}