You are here

protected function ContentImporter::processSerializedFields in Content Synchronization 8.2

Same name and namespace in other branches
  1. 3.0.x src/Importer/ContentImporter.php \Drupal\content_sync\Importer\ContentImporter::processSerializedFields()

Serializes fields which have to be stored serialized.

Parameters

$entity: The entity to update.

Return value

mixed The entity with the fields being serialized.

1 call to ContentImporter::processSerializedFields()
ContentImporter::prepareEntity in src/Importer/ContentImporter.php

File

src/Importer/ContentImporter.php, line 205

Class

ContentImporter

Namespace

Drupal\content_sync\Importer

Code

protected function processSerializedFields($entity) {
  foreach ($entity
    ->getTypedData() as $name => $field_items) {
    foreach ($field_items as $field_item) {

      // The field to be stored in a serialized way.
      if (!empty($this
        ->getCustomSerializedPropertyNames($field_item))) {
        $unserialized_value = $field_item
          ->get('value')
          ->getValue();
        $entity
          ->set($name, is_array($unserialized_value) ? serialize($unserialized_value) : $unserialized_value);
      }
    }
  }
  return $entity;
}