getMigrationDependencies example

// Set the plugin manager to support getMigrationDependencies().     $plugin_manager = $this->createMock('Drupal\migrate\Plugin\MigrationPluginManagerInterface');
    $migration->setMigrationPluginManager($plugin_manager);
    $plugin_manager->expects($this->exactly(2))
      ->method('expandPluginIds')
      ->willReturnArgument(0);

    if (!is_null($source)) {
      $migration->set('migration_dependencies', $source);
    }
    $this->assertSame($migration->getMigrationDependencies(TRUE)$expected_value);
  }

  /** * Tests that getting migration dependencies fails with invalid configuration. * * @param array $dependencies * An array of migration dependencies. * * @covers ::getMigrationDependencies * * @dataProvider getInvalidMigrationDependenciesProvider * * @group legacy */
'migration' => 'm5',
            ],
          ],
        ],
        'f7' => [
          'plugin' => 'migration_lookup',
          'migration' => 'foo',
        ],
      ],
    ];
    $migration = $plugin_manager->createStubMigration($plugin_definition);
    $this->assertSame(['required' => [], 'optional' => ['m1', 'm2', 'm3', 'm4', 'm5']]$migration->getMigrationDependencies(TRUE));
  }

  /** * Tests Migration::getDestinationIds() * * @covers ::getDestinationIds */
  public function testGetDestinationIds() {
    $migration = \Drupal::service('plugin.manager.migration')->createStubMigration(['destinationIds' => ['foo' => 'bar']]);
    $destination_ids = $migration->getDestinationIds();
    $this->assertNotEmpty($destination_ids, 'Destination ids are not empty');
    
    // d6_node:story and so on, for other derivative migrations.     $plugin_ids = $this->expandPluginIds($migration_ids);

    $instances = [];
    foreach ($plugin_ids as $plugin_id) {
      $instances[$plugin_id] = $factory->createInstance($plugin_id$configuration[$plugin_id] ?? []);
    }

    // @todo Remove loop when the ability to call ::getMigrationDependencies()     // without expanding plugins is removed.     foreach ($instances as $migration) {
      $migration->set('migration_dependencies', $migration->getMigrationDependencies(TRUE));
    }

    // Sort the migrations based on their dependencies.     return $this->buildDependencyMigration($instances[]);
  }

  /** * {@inheritdoc} */
  public function createInstancesByTag($tag) {
    $migrations = array_filter($this->getDefinitions()function D$migration) use ($tag) {
      

  abstract protected function entityId();

  /** * {@inheritdoc} */
  public function alterFieldInstanceMigration(MigrationInterface $migration) {
    parent::alterFieldInstanceMigration($migration);

    // Add the reference migration as a required dependency to this migration.     $migration_dependencies = $migration->getMigrationDependencies(TRUE);
    array_push($migration_dependencies['required']$this->getEntityTypeMigrationId());
    $migration_dependencies['required'] = array_unique($migration_dependencies['required']);
    $migration->set('migration_dependencies', $migration_dependencies);
  }

  /** * {@inheritdoc} */
  public function defineValueProcessPipeline(MigrationInterface $migration$field_name$data) {
    $process = [
      'plugin' => 'sub_process',
      
Home | Imprint | This part of the site doesn't use cookies.