3 namespace Drupal\taxonomy\Plugin\migrate;
5 use Drupal\Component\Plugin\Derivative\DeriverBase;
6 use Drupal\Component\Plugin\PluginManagerInterface;
7 use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
8 use Drupal\migrate\Plugin\MigrationDeriverTrait;
9 use Symfony\Component\DependencyInjection\ContainerInterface;
12 * Deriver for Drupal 6 term node migrations based on vocabularies.
14 class D6TermNodeDeriver extends DeriverBase implements ContainerDeriverInterface {
15 use MigrationDeriverTrait;
18 * The base plugin ID this derivative is for.
22 protected $basePluginId;
25 * The migration plugin manager.
27 * @var \Drupal\Component\Plugin\PluginManagerInterface
29 protected $migrationPluginManager;
32 * D6TermNodeDeriver constructor.
34 * @param string $base_plugin_id
35 * The base plugin ID this derivative is for.
36 * @param \Drupal\Component\Plugin\PluginManagerInterface $migration_plugin_manager
37 * The migration plugin manager.
39 public function __construct($base_plugin_id, PluginManagerInterface $migration_plugin_manager) {
40 $this->basePluginId = $base_plugin_id;
41 $this->migrationPluginManager = $migration_plugin_manager;
47 public static function create(ContainerInterface $container, $base_plugin_id) {
50 $container->get('plugin.manager.migration')
57 public function getDerivativeDefinitions($base_plugin_definition, $base_plugin_definitions = NULL) {
59 foreach (static::getSourcePlugin('d6_taxonomy_vocabulary') as $row) {
60 $source_vid = $row->getSourceProperty('vid');
61 $definition = $base_plugin_definition;
62 $definition['source']['vid'] = $source_vid;
63 // migrate_drupal_migration_plugins_alter() adds to this definition.
64 $this->derivatives[$source_vid] = $definition;
67 catch (\Exception $e) {
68 // It is possible no D6 tables are loaded so just eat exceptions.
70 return $this->derivatives;