You are here

public function EmbeddedEntityImporter::prepareImportableEntityData in Entity Share 8.3

Method called on STAGE_PREPARE_IMPORTABLE_ENTITY_DATA.

If the plugin reacts to this stage.

Parameters

\Drupal\entity_share_client\RuntimeImportContext $runtime_import_context: The import context.

array $entity_json_data: The entity JSON data.

Overrides ImportProcessorPluginBase::prepareImportableEntityData

File

modules/entity_share_client/src/Plugin/EntityShareClient/Processor/EmbeddedEntityImporter.php, line 32

Class

EmbeddedEntityImporter
Import embedded entities from text formatted fields.

Namespace

Drupal\entity_share_client\Plugin\EntityShareClient\Processor

Code

public function prepareImportableEntityData(RuntimeImportContext $runtime_import_context, array &$entity_json_data) {

  // Parse entity data to extract urls to get block content from block
  // field. And remove this info.
  if (isset($entity_json_data['attributes']) && is_array($entity_json_data['attributes'])) {
    foreach ($entity_json_data['attributes'] as $field_data) {
      if (is_array($field_data)) {
        if (EntityShareUtility::isNumericArray($field_data)) {
          foreach ($field_data as $value) {

            // Detect formatted text fields.
            if (isset($value['format']) && isset($value['value'])) {
              $this
                ->parseFormattedTextAndImport($runtime_import_context, $value['value']);
            }
          }
        }
        elseif (isset($field_data['format']) && isset($field_data['value'])) {
          $this
            ->parseFormattedTextAndImport($runtime_import_context, $field_data['value']);
        }
      }
    }
  }
}