Commit 887850ec authored by webchick's avatar webchick

Issue #2484405 by phenaproxima, quietone, neclimdul: User pictures do not need...

Issue #2484405 by phenaproxima, quietone, neclimdul: User pictures do not need a dedicated process plugin
parent 30fceb5f
......@@ -23,7 +23,8 @@ process:
migration: d6_user_role
source: roles
user_picture:
plugin: d6_user_picture
plugin: migration
migration: d6_user_picture_file
source: uid
destination:
plugin: entity:user
......@@ -33,5 +34,5 @@ migration_dependencies:
- d6_user_role
optional:
- d6_user_picture_file
- d6_user_picture_entity_display
- d6_user_picture_entity_form_display
- user_picture_entity_display
- user_picture_entity_form_display
......@@ -24,7 +24,10 @@ process:
plugin: migration
migration: d7_user_role
source: roles
user_picture: picture
user_picture:
plugin: migration
migration: d7_file
source: picture
destination:
plugin: entity:user
migration_dependencies:
......
<?php
/**
* @file
* Contains \Drupal\user\Plugin\migrate\process\d6\UserPicture.
*/
namespace Drupal\user\Plugin\migrate\process\d6;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Plugin\MigrateProcessInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* The user picture process plugin.
*
* @MigrateProcessPlugin(
* id = "d6_user_picture"
* )
*/
class UserPicture extends ProcessPluginBase implements ContainerFactoryPluginInterface {
/**
* The migration plugin.
*
* @var \Drupal\migrate\Plugin\MigrateProcessInterface
*/
protected $migrationPlugin;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, MigrationInterface $migration, MigrateProcessInterface $migration_plugin) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->migration = $migration;
$this->migrationPlugin = $migration_plugin;
}
/**
* {@inheritdoc}
*/
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('plugin.manager.migrate.process')->createInstance('migration', array('migration' => 'd6_user_picture_file'), $migration)
);
}
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
return $row->getSourceProperty('picture') ? $this->migrationPlugin->transform($value, $migrate_executable, $row, $destination_property) : NULL;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment