Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / taxonomy / src / Plugin / migrate / source / d6 / VocabularyTranslation.php
1 <?php
2
3 namespace Drupal\taxonomy\Plugin\migrate\source\d6;
4
5 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
6
7 /**
8  * Drupal 6 vocabulary translations from source database.
9  *
10  * @MigrateSource(
11  *   id = "d6_taxonomy_vocabulary_translation",
12  *   source_provider = "taxonomy"
13  * )
14  */
15 class VocabularyTranslation extends DrupalSqlBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function query() {
21     $query = $this->select('vocabulary', 'v')
22       ->fields('v', ['vid', 'name', 'description'])
23       ->fields('i18n', ['lid', 'type', 'property', 'objectid'])
24       ->fields('lt', ['lid', 'translation'])
25       ->condition('i18n.type', 'vocabulary');
26     $query->addField('lt', 'language', 'language');
27     // The i18n_strings table has two columns containing the object ID, objectid
28     // and objectindex. The objectid column is a text field. Therefore, for the
29     // join to work in PostgreSQL, use the objectindex field as this is numeric
30     // like the vid field.
31     $query->join('i18n_strings', 'i18n', 'v.vid = i18n.objectindex');
32     $query->leftJoin('locales_target', 'lt', 'lt.lid = i18n.lid');
33
34     return $query;
35   }
36
37   /**
38    * {@inheritdoc}
39    */
40   public function fields() {
41     return [
42       'vid' => $this->t('The vocabulary ID.'),
43       'language' => $this->t('Language for this field.'),
44       'property' => $this->t('Name of property being translated.'),
45       'translation' => $this->t('Translation of either the title or explanation.'),
46     ];
47   }
48
49   /**
50    * {@inheritdoc}
51    */
52   public function getIds() {
53     $ids['vid']['type'] = 'integer';
54     return $ids;
55   }
56
57 }