public function BlockFieldBlockContentImporter::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/ BlockFieldBlockContentImporter.php, line 28
Class
- BlockFieldBlockContentImporter
- Import block contents from block fields.
Namespace
Drupal\entity_share_client\Plugin\EntityShareClient\ProcessorCode
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_name => $field_data) {
if (is_array($field_data)) {
if (EntityShareUtility::isNumericArray($field_data)) {
foreach ($field_data as $delta => $value) {
if (isset($value['block_content_href'])) {
$this
->importUrl($runtime_import_context, $value['block_content_href']);
unset($entity_json_data['attributes'][$field_name][$delta]['block_content_href']);
}
}
}
elseif (isset($field_data['block_content_href'])) {
$this
->importUrl($runtime_import_context, $field_data['block_content_href']);
unset($entity_json_data['attributes'][$field_name]['block_content_href']);
}
}
}
}
}