You are here

class D6TermNodeDeriver in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/taxonomy/src/Plugin/migrate/D6TermNodeDeriver.php \Drupal\taxonomy\Plugin\migrate\D6TermNodeDeriver
  2. 9 core/modules/taxonomy/src/Plugin/migrate/D6TermNodeDeriver.php \Drupal\taxonomy\Plugin\migrate\D6TermNodeDeriver

Deriver for Drupal 6 term node migrations based on vocabularies.

Hierarchy

  • class \Drupal\taxonomy\Plugin\migrate\D6TermNodeDeriver extends \Drupal\Component\Plugin\Derivative\DeriverBase implements \Drupal\Core\Plugin\Discovery\ContainerDeriverInterface uses \Drupal\migrate\Plugin\MigrationDeriverTrait

Expanded class hierarchy of D6TermNodeDeriver

3 string references to 'D6TermNodeDeriver'
d6_term_node.yml in core/modules/taxonomy/migrations/d6_term_node.yml
core/modules/taxonomy/migrations/d6_term_node.yml
d6_term_node_revision.yml in core/modules/taxonomy/migrations/d6_term_node_revision.yml
core/modules/taxonomy/migrations/d6_term_node_revision.yml
d6_term_node_translation.yml in core/modules/content_translation/migrations/d6_term_node_translation.yml
core/modules/content_translation/migrations/d6_term_node_translation.yml

File

core/modules/taxonomy/src/Plugin/migrate/D6TermNodeDeriver.php, line 14

Namespace

Drupal\taxonomy\Plugin\migrate
View source
class D6TermNodeDeriver extends DeriverBase implements ContainerDeriverInterface {
  use MigrationDeriverTrait;

  /**
   * The base plugin ID this derivative is for.
   *
   * @var string
   */
  protected $basePluginId;

  /**
   * The migration plugin manager.
   *
   * @var \Drupal\Component\Plugin\PluginManagerInterface
   */
  protected $migrationPluginManager;

  /**
   * D6TermNodeDeriver constructor.
   *
   * @param string $base_plugin_id
   *   The base plugin ID this derivative is for.
   * @param \Drupal\Component\Plugin\PluginManagerInterface $migration_plugin_manager
   *   The migration plugin manager.
   */
  public function __construct($base_plugin_id, PluginManagerInterface $migration_plugin_manager) {
    $this->basePluginId = $base_plugin_id;
    $this->migrationPluginManager = $migration_plugin_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($base_plugin_id, $container
      ->get('plugin.manager.migration'));
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition, $base_plugin_definitions = NULL) {
    try {
      foreach (static::getSourcePlugin('d6_taxonomy_vocabulary') as $row) {
        $source_vid = $row
          ->getSourceProperty('vid');
        $definition = $base_plugin_definition;
        $definition['source']['vid'] = $source_vid;

        // migrate_drupal_migration_plugins_alter() adds to this definition.
        $this->derivatives[$source_vid] = $definition;
      }
    } catch (\Exception $e) {

      // It is possible no D6 tables are loaded so just eat exceptions.
    }
    return $this->derivatives;
  }

}

Members