bc2671a9c4a5dab8b97609ad5ea4577836795c23
[yaffs-website] / web / core / modules / field / src / Plugin / migrate / source / d6 / FieldOptionTranslation.php
1 <?php
2
3 namespace Drupal\field\Plugin\migrate\source\d6;
4
5 /**
6  * Gets field option label translations.
7  *
8  * @MigrateSource(
9  *   id = "d6_field_option_translation",
10  *   source_module = "i18ncck"
11  * )
12  */
13 class FieldOptionTranslation extends Field {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function query() {
19     // Get the fields that have field options translations.
20     $query = $this->select('i18n_strings', 'i18n')
21       ->fields('i18n')
22       ->fields('lt', [
23         'translation',
24         'language',
25         'plid',
26         'plural',
27         'i18n_status',
28       ])
29       ->condition('i18n.type', 'field')
30       ->condition('property', 'option\_%', 'LIKE')
31       ->isNotNull('translation');
32     $query->leftJoin('locales_target', 'lt', 'lt.lid = i18n.lid');
33     $query->leftjoin('content_node_field', 'cnf', 'cnf.field_name = i18n.objectid');
34     $query->addField('cnf', 'field_name');
35     $query->addField('cnf', 'global_settings');
36     // Minimise changes to the d6_field_option_translation.yml, which is copied
37     // from d6_field.yml, by ensuring the 'type' property is from
38     // content_node_field table.
39     $query->addField('cnf', 'type');
40     $query->addField('i18n', 'type', 'i18n_type');
41
42     return $query;
43   }
44
45   /**
46    * {@inheritdoc}
47    */
48   public function fields() {
49     $fields = [
50       'property' => $this->t('Option ID.'),
51       'objectid' => $this->t('Object ID'),
52       'objectindex' => $this->t('Integer value of Object ID'),
53       'format' => $this->t('The input format used by this string'),
54       'lid' => $this->t('Source string ID'),
55       'language' => $this->t('Language code'),
56       'translation' => $this->t('Translation of the option'),
57       'plid' => $this->t('Parent lid'),
58       'plural' => $this->t('Plural index number in case of plural strings'),
59     ];
60     return parent::fields() + $fields;
61   }
62
63   /**
64    * {@inheritdoc}
65    */
66
67   /**
68    * {@inheritdoc}
69    */
70   public function getIds() {
71     return parent::getIds() +
72       [
73         'language' => ['type' => 'string'],
74         'property' => ['type' => 'string'],
75       ];
76   }
77
78 }