cb748aec223e8c398fa0510e529bf90da9b9a70c
[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  * )
14  */
15 class LanguageContentSettings extends DrupalSqlBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function query() {
21     return $this->select('node_type', 't')
22       ->fields('t', [
23         'type',
24       ]);
25   }
26
27   /**
28    * {@inheritdoc}
29    */
30   public function fields() {
31     $fields = [
32       'type' => $this->t('Type'),
33       'language_content_type' => $this->t('Multilingual support.'),
34       'i18n_lock_node' => $this->t('Lock language.'),
35     ];
36     return $fields;
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function prepareRow(Row $row) {
43     $type = $row->getSourceProperty('type');
44     $row->setSourceProperty('language_content_type', $this->variableGet('language_content_type_' . $type, NULL));
45     $i18n_node_options = $this->variableGet('i18n_node_options_' . $type, NULL);
46     if ($i18n_node_options && in_array('lock', $i18n_node_options)) {
47       $row->setSourceProperty('i18n_lock_node', 1);
48     }
49     else {
50       $row->setSourceProperty('i18n_lock_node', 0);
51     }
52     return parent::prepareRow($row);
53   }
54
55   /**
56    * {@inheritdoc}
57    */
58   public function getIds() {
59     $ids['type']['type'] = 'string';
60     return $ids;
61   }
62
63 }