Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = NULL)
 {
     /** @var \Drupal\migrate\Entity\MigrationInterface $bundle_migration */
     $bundle_migration = $storage->load('d6_taxonomy_vocabulary');
     $migrate_executable = new MigrateExecutable($bundle_migration, new MigrateMessage());
     $process = array_intersect_key($bundle_migration->get('process'), $bundle_migration->getDestinationPlugin()->getIds());
     $migrations = array();
     $vid_map = array();
     foreach ($bundle_migration->getIdMap() as $key => $value) {
         $old_vid = unserialize($key)['sourceid1'];
         $new_vid = $value['destid1'];
         $vid_map[$old_vid] = $new_vid;
     }
     foreach ($bundle_migration->getSourcePlugin()->getIterator() as $source_row) {
         $row = new Row($source_row, $source_row);
         $migrate_executable->processRow($row, $process);
         $old_vid = $source_row['vid'];
         $new_vid = $row->getDestinationProperty('vid');
         $vid_map[$old_vid] = $new_vid;
     }
     foreach ($vid_map as $old_vid => $new_vid) {
         $values = $this->migration->toArray();
         $migration_id = $this->migration->id() . ':' . $old_vid;
         $values['id'] = $migration_id;
         $values['source']['vid'] = $old_vid;
         $values['process'][$new_vid] = 'tid';
         $migrations[$migration_id] = $storage->create($values);
     }
     return $migrations;
 }
Exemple #2
0
 /**
  * Builds a map of source vocabulary IDs to expected destination IDs.
  *
  * @param array $source
  *   Additional configuration for the d6_taxonomy_vocabulary source.
  *
  * @return array
  *   The vid map. The keys are the source IDs and the values are the
  *   (expected) destination IDs.
  */
 protected function getVocabularyIdMap(array $source)
 {
     $map = [];
     $template = $this->templateStorage->getTemplateByName('d6_taxonomy_vocabulary');
     $template['source'] += $source;
     $migration = Migration::create($template);
     $executable = new MigrateExecutable($migration, new MigrateMessage());
     // Only process the destination ID properties.
     $process = array_intersect_key($template['process'], $migration->getDestinationPlugin()->getIds());
     foreach ($migration->getSourcePlugin() as $source_row) {
         // Process the row to generate the expected destination ID.
         $executable->processRow($source_row, $process);
         $map[$source_row->getSourceProperty('vid')] = $source_row->getDestinationProperty('vid');
     }
     return $map;
 }
 /**
  * Runs the process pipeline for the current key.
  *
  * @param string|int $key
  *   The current key.
  * @param \Drupal\migrate\MigrateExecutable $migrate_executable
  *   The migrate executable helper class.
  * @param \Drupal\migrate\Row $row
  *   The current row after processing.
  *
  * @return mixed
  *   The transformed key.
  */
 protected function transformKey($key, MigrateExecutable $migrate_executable, Row $row)
 {
     $process = array('key' => $this->configuration['key']);
     $migrate_executable->processRow($row, $process, $key);
     return $row->getDestinationProperty('key');
 }