You are here

protected function BuilderBase::getSourcePlugin in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate/src/Plugin/migrate/builder/BuilderBase.php \Drupal\migrate\Plugin\migrate\builder\BuilderBase::getSourcePlugin()

Returns a fully initialized instance of a source plugin.

Parameters

string $plugin_id: The plugin ID.

array $configuration: (optional) Additional configuration for the plugin.

Return value

\Drupal\migrate\Plugin\MigrateSourceInterface|\Drupal\migrate\Plugin\RequirementsInterface The fully initialized source plugin.

4 calls to BuilderBase::getSourcePlugin()
Node::buildMigrations in core/modules/node/src/Plugin/migrate/builder/d6/Node.php
Builds migration entities based on a template.
Node::buildMigrations in core/modules/node/src/Plugin/migrate/builder/d7/Node.php
Builds migration entities based on a template.
ProfileValues::buildMigrations in core/modules/user/src/Plugin/migrate/builder/d6/ProfileValues.php
Builds migration entities based on a template.
User::buildMigrations in core/modules/user/src/Plugin/migrate/builder/d7/User.php
Builds migration entities based on a template.

File

core/modules/migrate/src/Plugin/migrate/builder/BuilderBase.php, line 30
Contains \Drupal\migrate\Plugin\migrate\builder\BuilderBase.

Class

BuilderBase
Base class for builder plugins.

Namespace

Drupal\migrate\Plugin\migrate\builder

Code

protected function getSourcePlugin($plugin_id, array $configuration = []) {
  $configuration['plugin'] = $plugin_id;

  // By default, SqlBase subclasses will try to join on a map table. But in
  // this case we're trying to use the source plugin as a detached iterator
  // over the source data, so we don't want to join on (or create) the map
  // table.
  // @see SqlBase::initializeIterator()
  $configuration['ignore_map'] = TRUE;

  // Source plugins are tightly coupled to migration entities, so we need
  // to create a fake migration in order to properly initialize the plugin.
  $values = [
    'id' => uniqid(),
    'source' => $configuration,
    // Since this isn't a real migration, we don't want a real destination --
    // the 'null' destination is perfect for this.
    'destination' => [
      'plugin' => 'null',
    ],
  ];
  return Migration::create($values)
    ->getSourcePlugin();
}