getDestinationModule example

protected function buildDiscoveredDestinationsBySource($version, array $migrations, array $source_system_data) {
    $discovered_upgrade_paths = [];
    $table_data = [];
    foreach ($migrations as $migration) {
      $migration_id = $migration->getPluginId();
      $source_module = $migration->getSourcePlugin()->getSourceModule();
      if (!$source_module) {
        $this->messenger()
          ->addError($this->t('Source module not found for @migration_id.', ['@migration_id' => $migration_id]));
      }
      $destination_module = $migration->getDestinationPlugin()
        ->getDestinationModule();
      if (!$destination_module) {
        $this->messenger()
          ->addError($this->t('Destination module not found for @migration_id.', ['@migration_id' => $migration_id]));
      }

      if ($source_module && $destination_module) {
        $discovered_upgrade_paths[$source_module][] = $destination_module;
        $table_data[$source_module][$destination_module][$migration_id] = $migration->label();
      }
    }

    
foreach ($migrations as $migration) {
      $definition = $migration->getPluginDefinition();
      if (is_array($definition['provider'])) {
        $provider = reset($definition['provider']);
      }
      else {
        $provider = $definition['provider'];
      }

      $source_module = $migration->getSourcePlugin()->getSourceModule();
      $destination_module = $migration->getDestinationPlugin()
        ->getDestinationModule();

      $discovered[] = implode($separator[
        $provider,
        $source_module,
        $destination_module,
      ]);
    }

    // Add the field migrations.     /** @var \Drupal\migrate\Plugin\MigrationPluginManager $plugin_manager */
    $definitions = $this->container->get('plugin.manager.migrate.field')
      
->willReturn(array_combine(array_keys($files)array_map(function D$module) use ($url) {
        return $url . '/' . $module;
      }array_keys($files))));
    $migrationState = new MigrationState($fieldPluginManager->reveal()$moduleHandler->reveal()$this->createMock(MessengerInterface::class)$this->getStringTranslationStub());

    $all_migrations = [];
    foreach ($migrations as $name => $values) {
      $migration = $this->prophesize(MigrationInterface::class);
      $source = $this->prophesize(MigrateSourceInterface::class);
      $destination = $this->prophesize(MigrateDestinationInterface::class);
      $source->getSourceModule()->willReturn($values['source_module']);
      $destination->getDestinationModule()
        ->willReturn($values['destination_module']);
      $migration->getSourcePlugin()->willReturn($source->reveal());
      $migration->getDestinationPlugin()->willReturn($destination->reveal());
      $migration->getPluginId()->willReturn($name);
      $migration->label()->willReturn($name);
      $all_migrations[] = $migration->reveal();
    }

    // Tests Drupal 7 states.     $states = $migrationState->getUpgradeStates(7, $source_system_data$all_migrations);
    $this->assertEquals($expected_7$states);
    
Home | Imprint | This part of the site doesn't use cookies.