diff --git a/core/modules/migrate/src/Plugin/MigrationDeriverTrait.php b/core/modules/migrate/src/Plugin/MigrationDeriverTrait.php new file mode 100644 index 0000000..00e4fab --- /dev/null +++ b/core/modules/migrate/src/Plugin/MigrationDeriverTrait.php @@ -0,0 +1,40 @@ + [ + 'ignore_map' => TRUE, + 'plugin' => $source_plugin_id, + ], + 'destination' => [ + 'plugin' => 'null', + ], + ]; + return (new Migration([], uniqid(), $definition))->getSourcePlugin(); + } + +} diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/D6NodeDeriver.php b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php similarity index 84% rename from core/modules/migrate_drupal/src/Plugin/migrate/D6NodeDeriver.php rename to core/modules/node/src/Plugin/migrate/D6NodeDeriver.php index a1a73ce..0784c89 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/D6NodeDeriver.php +++ b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php @@ -12,12 +12,14 @@ use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Drupal\migrate\Exception\RequirementsException; use Drupal\migrate\Plugin\Migration; +use Drupal\migrate\Plugin\MigrationDeriverTrait; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Deriver for Drupal 6 node and node revision migrations based on node types. */ class D6NodeDeriver extends DeriverBase implements ContainerDeriverInterface { + use MigrationDeriverTrait; /** * @var bool @@ -126,29 +128,4 @@ public function getDerivativeDefinitions($base_plugin_definition) { return $this->derivatives; } - /** - * Returns a fully initialized instance of a source plugin. - * - * @param string $plugin_id - * The plugin ID. - * @param array $configuration - * (optional) Additional configuration for the plugin. Defaults to an empty - * array. - * - * @return \Drupal\migrate\Plugin\MigrateSourceInterface|\Drupal\migrate\Plugin\RequirementsInterface - * The fully initialized source plugin. - */ - public static function getSourcePlugin($source_plugin_id) { - $definition = [ - 'source' => [ - 'ignore_map' => TRUE, - 'plugin' => $source_plugin_id, - ], - 'destination' => [ - 'plugin' => 'null', - ], - ]; - return (new Migration([], uniqid(), $definition))->getSourcePlugin(); - } - } diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/D7NodeDeriver.php b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php similarity index 90% rename from core/modules/migrate_drupal/src/Plugin/migrate/D7NodeDeriver.php rename to core/modules/node/src/Plugin/migrate/D7NodeDeriver.php index 84a5f5b..cfbd663 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/D7NodeDeriver.php +++ b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php @@ -2,21 +2,23 @@ /** * @file - * Contains \Drupal\migrate_drupal\Plugin\migrate\D7NodeDeriver. + * Contains \Drupal\node\Plugin\migrate\D7NodeDeriver. */ -namespace Drupal\migrate_drupal\Plugin\migrate; +namespace Drupal\node\Plugin\migrate; use Drupal\Component\Plugin\Derivative\DeriverBase; use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Drupal\migrate\Plugin\Migration; +use Drupal\migrate\Plugin\MigrationDeriverTrait; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Deriver for Drupal 7 node and node revision migrations based on node types. */ class D7NodeDeriver extends DeriverBase implements ContainerDeriverInterface { + use MigrationDeriverTrait; /** * @var bool @@ -63,13 +65,13 @@ public function getDerivativeDefinitions($base_plugin_definition) { try { // Read all field instance definitions in the source database. $fields = array(); - foreach (D6NodeDeriver::getSourcePlugin('d7_field_instance') as $row) { + foreach (static::getSourcePlugin('d7_field_instance') as $row) { if ($row->getSourceProperty('entity_type') == 'node') { $fields[$row->getSourceProperty('bundle')][$row->getSourceProperty('field_name')] = $row->getSource(); } } - foreach (D6NodeDeriver::getSourcePlugin('d7_node_type') as $row) { + foreach (static::getSourcePlugin('d7_node_type') as $row) { $node_type = $row->getSourceProperty('type'); $values = $base_plugin_definition; $derivative_id = $node_type; diff --git a/core/modules/taxonomy/src/Plugin/migrate/D6TermNodeDeriver.php b/core/modules/taxonomy/src/Plugin/migrate/D6TermNodeDeriver.php index de5930a..8bcf6ae 100644 --- a/core/modules/taxonomy/src/Plugin/migrate/D6TermNodeDeriver.php +++ b/core/modules/taxonomy/src/Plugin/migrate/D6TermNodeDeriver.php @@ -10,13 +10,14 @@ use Drupal\Component\Plugin\Derivative\DeriverBase; use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; -use Drupal\migrate_drupal\Plugin\migrate\D6NodeDeriver; +use Drupal\migrate\Plugin\MigrationDeriverTrait; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Deriver for Drupal 6 term node migrations based on vocabularies. */ class D6TermNodeDeriver extends DeriverBase implements ContainerDeriverInterface { + use MigrationDeriverTrait; protected $basePluginId; @@ -40,7 +41,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { */ public function getDerivativeDefinitions($base_plugin_definition, $base_plugin_definitions = NULL) { try { - foreach (D6NodeDeriver::getSourcePlugin('d6_taxonomy_vocabulary') as $row) { + foreach (static::getSourcePlugin('d6_taxonomy_vocabulary') as $row) { $source_vid = $row->getSourceProperty('vid'); $definition = $base_plugin_definition; $definition['source']['vid'] = $source_vid;