Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / taxonomy / src / Plugin / migrate / source / d7 / Vocabulary.php
1 <?php
2
3 namespace Drupal\taxonomy\Plugin\migrate\source\d7;
4
5 use Drupal\migrate\Row;
6 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
7
8 /**
9  * Drupal 7 vocabularies source from database.
10  *
11  * @MigrateSource(
12  *   id = "d7_taxonomy_vocabulary",
13  *   source_module = "taxonomy"
14  * )
15  */
16 class Vocabulary extends DrupalSqlBase {
17
18   /**
19    * {@inheritdoc}
20    */
21   public function query() {
22     $query = $this->select('taxonomy_vocabulary', 'v')
23       ->fields('v', [
24         'vid',
25         'name',
26         'description',
27         'hierarchy',
28         'module',
29         'weight',
30         'machine_name',
31       ]);
32     return $query;
33   }
34
35   /**
36    * {@inheritdoc}
37    */
38   public function fields() {
39     return [
40       'vid' => $this->t('The vocabulary ID.'),
41       'name' => $this->t('The name of the vocabulary.'),
42       'description' => $this->t('The description of the vocabulary.'),
43       'hierarchy' => $this->t('The type of hierarchy allowed within the vocabulary. (0 = disabled, 1 = single, 2 = multiple)'),
44       'module' => $this->t('Module responsible for the vocabulary.'),
45       'weight' => $this->t('The weight of the vocabulary in relation to other vocabularies.'),
46       'machine_name' => $this->t('Unique machine name of the vocabulary.'),
47     ];
48   }
49
50   /**
51    * {@inheritdoc}
52    */
53   public function prepareRow(Row $row) {
54     // If the vocabulary being migrated is the one defined in the
55     // 'forum_nav_vocabulary' variable, set the 'forum_vocabulary' source
56     // property to true so we know this is the vocabulary used by Forum.
57     if ($this->variableGet('forum_nav_vocabulary', 0) == $row->getSourceProperty('vid')) {
58       $row->setSourceProperty('forum_vocabulary', TRUE);
59     }
60
61     return parent::prepareRow($row);
62   }
63
64   /**
65    * {@inheritdoc}
66    */
67   public function getIds() {
68     $ids['vid']['type'] = 'integer';
69     return $ids;
70   }
71
72 }