You are here

public function FallbackFieldUnserializer::onUnserializeContentField in Acquia Content Hub 8.2

Naive handling for fields that don't have special handling.

Parameters

\Drupal\acquia_contenthub\Event\UnserializeCdfEntityFieldEvent $event: The unserialize event.

File

src/EventSubscriber/UnserializeContentField/FallbackFieldUnserializer.php, line 28

Class

FallbackFieldUnserializer
Generic field unserializer fallback subscriber.

Namespace

Drupal\acquia_contenthub\EventSubscriber\UnserializeContentField

Code

public function onUnserializeContentField(UnserializeCdfEntityFieldEvent $event) {
  $field = $event
    ->getField();
  $values = [];
  if (!empty($field['value'])) {
    foreach ($field['value'] as $langcode => $value) {
      $values[$langcode][$event
        ->getFieldName()] = $value;
    }
    $event
      ->setValue($values);
  }
  $event
    ->stopPropagation();
}