Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / block / src / Plugin / migrate / source / d6 / BlockTranslation.php
1 <?php
2
3 namespace Drupal\block\Plugin\migrate\source\d6;
4
5 use Drupal\block\Plugin\migrate\source\Block;
6 use Drupal\migrate\Plugin\migrate\source\SourcePluginBase;
7 use Drupal\migrate\Row;
8
9 /**
10  * Gets i18n block data from source database.
11  *
12  * @MigrateSource(
13  *   id = "d6_block_translation",
14  *   source_module = "i18nblocks"
15  * )
16  */
17 class BlockTranslation extends Block {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function query() {
23     // Let the parent set the block table to use, but do not use the parent
24     // query. Instead build a query so can use an inner join to the selected
25     // block table.
26     parent::query();
27     $query = $this->select('i18n_blocks', 'i18n')
28       ->fields('i18n')
29       ->fields('b', ['bid', 'module', 'delta', 'theme', 'title']);
30     $query->innerJoin($this->blockTable, 'b', ('b.module = i18n.module AND b.delta = i18n.delta'));
31     return $query;
32   }
33
34   /**
35    * {@inheritdoc}
36    */
37   public function fields() {
38     return [
39       'bid' => $this->t('The block numeric identifier.'),
40       'ibid' => $this->t('The i18n_blocks block numeric identifier.'),
41       'module' => $this->t('The module providing the block.'),
42       'delta' => $this->t("The block's delta."),
43       'type' => $this->t('Block type'),
44       'language' => $this->t('Language for this field.'),
45       'theme' => $this->t('Which theme the block is placed in.'),
46       'default_theme' => $this->t('The default theme.'),
47       'title' => $this->t('Block title.'),
48     ];
49   }
50
51   /**
52    * {@inheritdoc}
53    */
54   public function prepareRow(Row $row) {
55     $row->setSourceProperty('default_theme', $this->defaultTheme);
56     return SourcePluginBase::prepareRow($row);
57   }
58
59   /**
60    * {@inheritdoc}
61    */
62   public function getIds() {
63     $ids = parent::getIds();
64     $ids['module']['alias'] = 'b';
65     $ids['delta']['alias'] = 'b';
66     $ids['theme']['alias'] = 'b';
67     $ids['language']['type'] = 'string';
68     return $ids;
69   }
70
71 }