protected function FilePlainConfigSourceBase::initializeIterator in Media Migration 8
1 call to FilePlainConfigSourceBase::initializeIterator()
- FilePlainFieldFormatter::initializeIterator in src/
Plugin/ migrate/ source/ d7/ FilePlainFieldFormatter.php
2 methods override FilePlainConfigSourceBase::initializeIterator()
- FilePlainFieldFormatter::initializeIterator in src/
Plugin/ migrate/ source/ d7/ FilePlainFieldFormatter.php - FilePlainSourceFieldInstance::initializeIterator in src/
Plugin/ migrate/ source/ d7/ FilePlainSourceFieldInstance.php
File
- src/
Plugin/ migrate/ source/ d7/ FilePlainConfigSourceBase.php, line 119
Class
- FilePlainConfigSourceBase
- Base class for config migrate source plugins of plain file migrations.
Namespace
Drupal\media_migration\Plugin\migrate\source\d7Code
protected function initializeIterator() {
$results = $this
->prepareQuery()
->execute()
->fetchAll();
// Add the array of all instances using the same media type to each row.
$rows = [];
foreach ($results as $result) {
[
'mime' => $mime,
'scheme' => $scheme,
] = $result;
if (!($dealer_plugin = $this->fileDealerManager
->createInstanceFromSchemeAndMime($scheme, $mime))) {
continue;
}
$destination_media_type_id = $dealer_plugin
->getDestinationMediaTypeId();
$source_values = $rows[$destination_media_type_id] ?? $result + [
'mimes' => $mime,
'schemes' => $scheme,
];
$source_values['mimes'] = implode(static::MULTIPLE_SEPARATOR, array_unique(array_merge(explode(static::MULTIPLE_SEPARATOR, $source_values['mimes']), [
$mime,
])));
$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['mime']);
unset($source_values['scheme']);
$rows[$destination_media_type_id] = $source_values;
}
return new \ArrayIterator($rows);
}