function taxonomy_update_8005

Convert vocabularies into configuration.

File

drupal/core/modules/taxonomy/taxonomy.install, line 297
Install, update and uninstall functions for the taxonomy module.

Code

function taxonomy_update_8005() {
  $uuid = new Uuid();
  $result = db_query('SELECT * FROM {taxonomy_vocabulary}');
  foreach ($result as $vocabulary) {
    $config = config('taxonomy.vocabulary.' . $vocabulary->machine_name)
      ->set('vid', $vocabulary->machine_name)
      ->set('name', $vocabulary->name)
      ->set('uuid', !empty($vocabulary->uuid) ? $vocabulary->uuid : $uuid
      ->generate())
      ->set('description', $vocabulary->description)
      ->set('hierarchy', $vocabulary->hierarchy)
      ->set('weight', $vocabulary->weight)
      ->set('langcode', $vocabulary->langcode)
      ->save();
  }
}