BlockFieldBlockContentImporter.php in Entity Share 8.3
File
modules/entity_share_client/src/Plugin/EntityShareClient/Processor/BlockFieldBlockContentImporter.php
View source
<?php
declare (strict_types=1);
namespace Drupal\entity_share_client\Plugin\EntityShareClient\Processor;
use Drupal\entity_share\EntityShareUtility;
use Drupal\entity_share_client\RuntimeImportContext;
class BlockFieldBlockContentImporter extends EntityReference {
public function prepareImportableEntityData(RuntimeImportContext $runtime_import_context, array &$entity_json_data) {
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']);
}
}
}
}
}
protected function importUrl(RuntimeImportContext $runtime_import_context, $url) {
if ($this->currentRecursionDepth == $this->configuration['max_recursion_depth']) {
return [];
}
return parent::importUrl($runtime_import_context, $url);
}
}