8d8338776db102487853b17eb2b6c8f0edb57372
[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  * )
14  */
15 class Config extends DrupalSqlBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function query() {
21     $query = $this->select('config', 'c')
22       ->fields('c', ['collection', 'name', 'data']);
23     if (!empty($this->configuration['collections'])) {
24       $query->condition('collection', (array) $this->configuration['collections'], 'IN');
25     }
26     if (!empty($this->configuration['names'])) {
27       $query->condition('name', (array) $this->configuration['names'], 'IN');
28     }
29     return $query;
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   public function prepareRow(Row $row) {
36     $row->setSourceProperty('data', unserialize($row->getSourceProperty('data')));
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function fields() {
43     return [
44       'collection' => $this->t('The config object collection.'),
45       'name' => $this->t('The config object name.'),
46       'data' => $this->t('Serialized configuration object data.'),
47     ];
48   }
49
50   /**
51    * {@inheritdoc}
52    */
53   public function getIds() {
54     $ids['collection']['type'] = 'string';
55     $ids['name']['type'] = 'string';
56     return $ids;
57   }
58
59 }