FieldFile.php in Drupal 10
File
core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php
View source
<?php
namespace Drupal\file\Plugin\migrate\process\d6;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\MigrateLookupInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FieldFile extends ProcessPluginBase implements ContainerFactoryPluginInterface {
protected $migrateLookup;
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, MigrateLookupInterface $migrate_lookup) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->migration = $migration;
$this->migrateLookup = $migrate_lookup;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
return new static($configuration, $plugin_id, $plugin_definition, $migration, $container
->get('migrate.lookup'));
}
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$options = unserialize($value['data']);
$lookup_result = $this->migrateLookup
->lookup('d6_file', [
$value['fid'],
]);
if ($lookup_result) {
return [
'target_id' => $lookup_result[0]['fid'],
'display' => $value['list'],
'description' => $options['description'] ?? '',
'alt' => $options['alt'] ?? '',
'title' => $options['title'] ?? '',
];
}
else {
return [];
}
}
}
Classes
Name |
Description |
FieldFile |
Plugin annotation
@MigrateProcessPlugin(
id = "d6_field_file"
) |