User.php in Zircon Profile 8.0
File
core/modules/user/src/Plugin/migrate/builder/d7/User.php
View source
<?php
namespace Drupal\user\Plugin\migrate\builder\d7;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\Plugin\migrate\builder\BuilderBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
class User extends BuilderBase implements ContainerFactoryPluginInterface {
protected $moduleHandler;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ModuleHandlerInterface $module_handler) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->moduleHandler = $module_handler;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('module_handler'));
}
public function buildMigrations(array $template) {
$migration = Migration::create($template);
if ($this->moduleHandler
->moduleExists('field')) {
$template['source']['entity_type'] = 'user';
$source_plugin = $this
->getSourcePlugin('d7_field_instance', $template['source']);
foreach ($source_plugin as $field) {
$field_name = $field
->getSourceProperty('field_name');
$migration
->setProcessOfProperty($field_name, $field_name);
}
}
try {
$profile_fields = $this
->getSourcePlugin('profile_field', $template['source']);
$profile_fields
->checkRequirements();
foreach ($profile_fields as $field) {
$field_name = $field
->getSourceProperty('name');
$migration
->setProcessOfProperty($field_name, $field_name);
}
} catch (RequirementsException $e) {
}
return [
$migration,
];
}
}
Classes
Name |
Description |
User |
Plugin annotation
@PluginID("d7_user"); |