protected function FileEntityConfigSourceBase::initializeIterator in Media Migration 8
1 call to FileEntityConfigSourceBase::initializeIterator()
- FileEntityFieldFormatter::initializeIterator in src/
Plugin/ migrate/ source/ d7/ FileEntityFieldFormatter.php
2 methods override FileEntityConfigSourceBase::initializeIterator()
- FileEntityFieldFormatter::initializeIterator in src/
Plugin/ migrate/ source/ d7/ FileEntityFieldFormatter.php - FileEntitySourceFieldInstance::initializeIterator in src/
Plugin/ migrate/ source/ d7/ FileEntitySourceFieldInstance.php
File
- src/
Plugin/ migrate/ source/ d7/ FileEntityConfigSourceBase.php, line 106
Class
- FileEntityConfigSourceBase
- Base class for config migrate source plugins of file entity migrations.
Namespace
Drupal\media_migration\Plugin\migrate\source\d7Code
protected function initializeIterator() {
$results = $this
->prepareQuery()
->execute()
->fetchAll();
$rows = [];
foreach ($results as $result) {
[
'type' => $type,
'scheme' => $scheme,
] = $result;
if (!($dealer_plugin = $this->fileEntityDealerManager
->createInstanceFromTypeAndScheme($type, $scheme))) {
continue;
}
$destination_media_type_id = $dealer_plugin
->getDestinationMediaTypeId();
$source_values = $rows[$destination_media_type_id] ?? $result + [
'types' => $type,
'schemes' => $scheme,
];
$source_values['types'] = implode(static::MULTIPLE_SEPARATOR, array_unique(array_merge(explode(static::MULTIPLE_SEPARATOR, $source_values['types']), [
$type,
])));
$source_values['schemes'] = implode(static::MULTIPLE_SEPARATOR, array_unique(array_merge(explode(static::MULTIPLE_SEPARATOR, $source_values['schemes']), [
$scheme,
])));
$source_values['bundle'] = $destination_media_type_id;
$source_values['bundle_label'] = $dealer_plugin
->getDestinationMediaTypeLabel();
$source_values['source_plugin_id'] = $dealer_plugin
->getDestinationMediaSourcePluginId();
$source_values['source_field_name'] = $dealer_plugin
->getDestinationMediaSourceFieldName();
$source_values['source_field_label'] = $dealer_plugin
->getDestinationMediaTypeSourceFieldLabel();
unset($source_values['type']);
unset($source_values['scheme']);
$rows[$destination_media_type_id] = $source_values;
}
return new \ArrayIterator($rows);
}