getMigrationPluginManager example

$this->getSourcePlugin()->checkRequirements();
    }
    if ($this->getDestinationPlugin() instanceof RequirementsInterface) {
      $this->getDestinationPlugin()->checkRequirements();
    }

    if (empty($this->requirements)) {
      // There are no requirements to check.       return;
    }
    /** @var \Drupal\migrate\Plugin\MigrationInterface[] $required_migrations */
    $required_migrations = $this->getMigrationPluginManager()->createInstances($this->requirements);

    $missing_migrations = array_diff($this->requirements, array_keys($required_migrations));
    // Check if the dependencies are in good shape.     foreach ($required_migrations as $migration_id => $required_migration) {
      if (!$required_migration->allRowsProcessed()) {
        $missing_migrations[] = $migration_id;
      }
    }
    if ($missing_migrations) {
      throw new RequirementsException('Missing migrations ' . implode(', ', $missing_migrations) . '.', ['requirements' => $missing_migrations]);
    }
  }

  public function testGetMigrationPluginManagerDeprecation() {
    $container = new ContainerBuilder();
    $migration_plugin_manager = $this->createMock(MigrationPluginManager::class);
    $container->set('plugin.manager.migration', $migration_plugin_manager);
    \Drupal::setContainer($container);

    $this->expectDeprecation('deprecated in drupal:9.5.0 and is removed from drupal:11.0.0. Use $this->migrationPluginManager instead. See https://www.drupal.org/node/3277306');
    $id_map = $this->getIdMap();
    $id_map->getMigrationPluginManager();
  }

}
/** * {@inheritdoc} */
  public function ensureTables() {
    parent::ensureTables();
  }

  /** * {@inheritdoc} */
  public function getMigrationPluginManager() {
    return parent::getMigrationPluginManager();
  }

}

  protected function getMigrations($database_state_key$drupal_version) {
    $version_tag = 'Drupal ' . $drupal_version;
    /** @var \Drupal\migrate\Plugin\MigrationInterface[] $all_migrations */
    $all_migrations = $this->getMigrationPluginManager()->createInstancesByTag($version_tag);

    // Unset the node migrations that should not run based on the type of node     // migration. That is, if this is a complete node migration then unset the     // classic node migrations and if this is a classic node migration then     // unset the complete node migrations.     $type = NodeMigrateType::getNodeMigrateType(\Drupal::database()$drupal_version);
    switch ($type) {
      case NodeMigrateType::NODE_MIGRATE_TYPE_COMPLETE:
        $patterns = '/(d' . $drupal_version . '_node:)|(d' . $drupal_version . '_node_translation:)|(d' . $drupal_version . '_node_revision:)|(d7_node_entity_translation:)/';
        break;

      
    $edits = $this->translatePostValues($this->getCredentials());

    // Start the upgrade process.     $this->drupalGet('/upgrade');
    $this->submitForm([], 'Continue');
    $this->submitForm($edits, 'Review upgrade');
    $this->submitForm([], 'I acknowledge I may lose data. Continue anyway.');
    $this->useTestMailCollector();
    $this->submitForm([], 'Perform upgrade');

    // Tests the migration log contains an error message.     $migration = $this->getMigrationPluginManager()->createInstance('d7_file');
    $messages = $migration->getIdMap()->getMessages();

    $count = 0;
    foreach ($messages as $message) {
      $count++;
      $this->assertStringContainsString('/migrate_drupal_ui/tests/src/Functional/d7/files/sites/default/files/foo.txt', $message->message);
      $this->assertSame(MigrationInterface::MESSAGE_ERROR, (int) $message->level);
    }
    $this->assertSame(1, $count);
  }

  
Home | Imprint | This part of the site doesn't use cookies.