Pull merge.
[yaffs-website] / web / core / modules / migrate_drupal / src / Plugin / migrate / source / d8 / Config.php
1 <?php
2
3 namespace Drupal\migrate_drupal\Plugin\migrate\source\d8;
4
5 use Drupal\migrate\Row;
6 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
7
8 /**
9  * Drupal config source from database.
10  *
11  * @MigrateSource(
12  *   id = "d8_config",
13  *   source_module = "system",
14  * )
15  */
16 class Config extends DrupalSqlBase {
17
18   /**
19    * {@inheritdoc}
20    */
21   public function query() {
22     $query = $this->select('config', 'c')
23       ->fields('c', ['collection', 'name', 'data']);
24     if (!empty($this->configuration['collections'])) {
25       $query->condition('collection', (array) $this->configuration['collections'], 'IN');
26     }
27     if (!empty($this->configuration['names'])) {
28       $query->condition('name', (array) $this->configuration['names'], 'IN');
29     }
30     return $query;
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public function prepareRow(Row $row) {
37     $row->setSourceProperty('data', unserialize($row->getSourceProperty('data')));
38   }
39
40   /**
41    * {@inheritdoc}
42    */
43   public function fields() {
44     return [
45       'collection' => $this->t('The config object collection.'),
46       'name' => $this->t('The config object name.'),
47       'data' => $this->t('Serialized configuration object data.'),
48     ];
49   }
50
51   /**
52    * {@inheritdoc}
53    */
54   public function getIds() {
55     $ids['collection']['type'] = 'string';
56     $ids['name']['type'] = 'string';
57     return $ids;
58   }
59
60 }