efe87086d551e848afc9bfc0ee3c2fe76a89c0c6
[yaffs-website] / web / core / modules / language / src / Plugin / migrate / source / d7 / LanguageContentSettings.php
1 <?php
2
3 namespace Drupal\language\Plugin\migrate\source\d7;
4
5 use Drupal\migrate\Row;
6 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
7
8 /**
9  * Drupal multilingual node settings from database.
10  *
11  * @MigrateSource(
12  *   id = "d7_language_content_settings",
13  *   source_module = "locale"
14  * )
15  */
16 class LanguageContentSettings extends DrupalSqlBase {
17
18   /**
19    * {@inheritdoc}
20    */
21   public function query() {
22     return $this->select('node_type', 't')
23       ->fields('t', [
24         'type',
25       ]);
26   }
27
28   /**
29    * {@inheritdoc}
30    */
31   public function fields() {
32     $fields = [
33       'type' => $this->t('Type'),
34       'language_content_type' => $this->t('Multilingual support.'),
35       'i18n_lock_node' => $this->t('Lock language.'),
36     ];
37     return $fields;
38   }
39
40   /**
41    * {@inheritdoc}
42    */
43   public function prepareRow(Row $row) {
44     $type = $row->getSourceProperty('type');
45     $row->setSourceProperty('language_content_type', $this->variableGet('language_content_type_' . $type, NULL));
46     $i18n_node_options = $this->variableGet('i18n_node_options_' . $type, NULL);
47     if ($i18n_node_options && in_array('lock', $i18n_node_options)) {
48       $row->setSourceProperty('i18n_lock_node', 1);
49     }
50     else {
51       $row->setSourceProperty('i18n_lock_node', 0);
52     }
53     return parent::prepareRow($row);
54   }
55
56   /**
57    * {@inheritdoc}
58    */
59   public function getIds() {
60     $ids['type']['type'] = 'string';
61     return $ids;
62   }
63
64 }