Pull merge.
[yaffs-website] / web / core / modules / block / src / Plugin / migrate / source / d7 / BlockTranslation.php
1 <?php
2
3 namespace Drupal\block\Plugin\migrate\source\d7;
4
5 use Drupal\block\Plugin\migrate\source\Block;
6
7 /**
8  * Gets i18n block data from source database.
9  *
10  * @MigrateSource(
11  *   id = "d7_block_translation",
12  *   source_module = "i18n_block"
13  * )
14  */
15 class BlockTranslation extends Block {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function query() {
21     // Let the parent set the block table to use, but do not use the parent
22     // query. Instead build a query so can use an inner join to the selected
23     // block table.
24     parent::query();
25     $query = $this->select('i18n_string', 'i18n')
26       ->fields('i18n')
27       ->fields('b', [
28         'bid',
29         'module',
30         'delta',
31         'theme',
32         'status',
33         'weight',
34         'region',
35         'custom',
36         'visibility',
37         'pages',
38         'title',
39         'cache',
40         'i18n_mode',
41       ])
42       ->fields('lt', [
43         'lid',
44         'translation',
45         'language',
46         'plid',
47         'plural',
48         'i18n_status',
49       ])
50       ->condition('i18n_mode', 1);
51     $query->leftjoin($this->blockTable, 'b', ('b.delta = i18n.objectid'));
52     $query->leftjoin('locales_target', 'lt', 'lt.lid = i18n.lid');
53     return $query;
54   }
55
56   /**
57    * {@inheritdoc}
58    */
59   public function fields() {
60     return [
61       'bid' => $this->t('The block numeric identifier.'),
62       'module' => $this->t('The module providing the block.'),
63       'delta' => $this->t("The block's delta."),
64       'theme' => $this->t('Which theme the block is placed in.'),
65       'status' => $this->t('Block enabled status'),
66       'weight' => $this->t('Block weight within region'),
67       'region' => $this->t('Theme region within which the block is set'),
68       'visibility' => $this->t('Visibility'),
69       'pages' => $this->t('Pages list.'),
70       'title' => $this->t('Block title.'),
71       'cache' => $this->t('Cache rule.'),
72       'i18n_mode' => $this->t('Multilingual mode'),
73       'lid' => $this->t('Language string ID'),
74       'textgroup' => $this->t('A module defined group of translations'),
75       'context' => $this->t('Full string ID for quick search: type:objectid:property.'),
76       'objectid' => $this->t('Object ID'),
77       'type' => $this->t('Object type for this string'),
78       'property' => $this->t('Object property for this string'),
79       'objectindex' => $this->t('Integer value of Object ID'),
80       'format' => $this->t('The {filter_format}.format of the string'),
81       'translation' => $this->t('Translation'),
82       'language' => $this->t('Language code'),
83       'plid' => $this->t('Parent lid'),
84       'plural' => $this->t('Plural index number'),
85       'i18n_status' => $this->t('Translation needs update'),
86     ];
87   }
88
89   /**
90    * {@inheritdoc}
91    */
92   public function getIds() {
93     $ids['delta']['type'] = 'string';
94     $ids['delta']['alias'] = 'b';
95     $ids['language']['type'] = 'string';
96     return $ids;
97   }
98
99 }