Chris@0: basePluginId = $base_plugin_id; Chris@18: $this->fieldDiscovery = $field_discovery; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public static function create(ContainerInterface $container, $base_plugin_id) { Chris@0: return new static( Chris@0: $base_plugin_id, Chris@18: $container->get('migrate_drupal.field_discovery') Chris@0: ); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getDerivativeDefinitions($base_plugin_definition) { Chris@0: Chris@0: $vocabulary_source_plugin = static::getSourcePlugin('d7_taxonomy_vocabulary'); Chris@0: try { Chris@0: $vocabulary_source_plugin->checkRequirements(); Chris@0: } Chris@0: catch (RequirementsException $e) { Chris@0: // If the d7_taxonomy_vocabulary requirements failed, that means we do not Chris@0: // have a Drupal source database configured - there is nothing to Chris@0: // generate. Chris@0: return $this->derivatives; Chris@0: } Chris@0: Chris@0: try { Chris@0: foreach ($vocabulary_source_plugin as $row) { Chris@0: $bundle = $row->getSourceProperty('machine_name'); Chris@0: $values = $base_plugin_definition; Chris@0: Chris@0: $values['label'] = t('@label (@type)', [ Chris@0: '@label' => $values['label'], Chris@0: '@type' => $row->getSourceProperty('name'), Chris@0: ]); Chris@0: $values['source']['bundle'] = $bundle; Chris@0: $values['destination']['default_bundle'] = $bundle; Chris@0: Chris@18: /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */ Chris@0: $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($values); Chris@18: $this->fieldDiscovery->addBundleFieldProcesses($migration, 'taxonomy_term', $bundle); Chris@0: $this->derivatives[$bundle] = $migration->getPluginDefinition(); Chris@0: } Chris@0: } Chris@0: catch (DatabaseExceptionWrapper $e) { Chris@0: // Once we begin iterating the source plugin it is possible that the Chris@0: // source tables will not exist. This can happen when the Chris@0: // MigrationPluginManager gathers up the migration definitions but we do Chris@0: // not actually have a Drupal 7 source database. Chris@0: } Chris@0: Chris@0: return $this->derivatives; Chris@0: } Chris@0: Chris@0: }