function forum_migrate_d7_taxonomy_vocabulary_prepare_row

Same name and namespace in other branches
  1. 11.x core/modules/forum/forum.module \forum_migrate_d7_taxonomy_vocabulary_prepare_row()

Implements hook_migrate_MIGRATION_ID_prepare_row().

File

core/modules/forum/forum.module, line 689

Code

function forum_migrate_d7_taxonomy_vocabulary_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
  // If the vocabulary being migrated is the one defined in the
  // 'forum_nav_vocabulary' variable, set the 'forum_vocabulary' source
  // property to true so we know this is the vocabulary used by Forum.
  $connection = $migration->getSourcePlugin()
    ->getDatabase();
  if ($connection) {
    if ($connection->schema()
      ->tableExists('variable')) {
      $query = $connection->select('variable', 'v')
        ->fields('v', [
        'value',
      ])
        ->condition('name', 'forum_nav_vocabulary');
      $result = $query->execute()
        ->fetchCol();
      if ($result) {
        $forum_nav_vocabulary = unserialize($result[0], [
          'allowed_classes' => FALSE,
        ]);
        if ($forum_nav_vocabulary == $row->getSourceProperty('vid')) {
          $row->setSourceProperty('forum_vocabulary', TRUE);
        }
      }
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.