You are here

public function User::buildMigrations in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Plugin/migrate/builder/d7/User.php \Drupal\user\Plugin\migrate\builder\d7\User::buildMigrations()

Builds migration entities based on a template.

Parameters

array $template: The parsed template.

Return value

\Drupal\migrate\Entity\MigrationInterface[] The unsaved migrations generated from the template.

Overrides MigrateBuilderInterface::buildMigrations

File

core/modules/user/src/Plugin/migrate/builder/d7/User.php, line 61
Contains \Drupal\user\Plugin\migrate\builder\d7\User.

Class

User
Plugin annotation @PluginID("d7_user");

Namespace

Drupal\user\Plugin\migrate\builder\d7

Code

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']);

    // Ensure that Profile is enabled in the source DB.
    $profile_fields
      ->checkRequirements();
    foreach ($profile_fields as $field) {
      $field_name = $field
        ->getSourceProperty('name');
      $migration
        ->setProcessOfProperty($field_name, $field_name);
    }
  } catch (RequirementsException $e) {

    // Profile is not enabled in the source DB, so don't do anything.
  }
  return [
    $migration,
  ];
}