Version 1
[yaffs-website] / web / core / modules / image / src / Plugin / migrate / source / d6 / ImageCachePreset.php
1 <?php
2
3 namespace Drupal\image\Plugin\migrate\source\d6;
4
5 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
6 use Drupal\migrate\Row;
7
8 /**
9  * Drupal 6 imagecache presets source from database.
10  *
11  * @MigrateSource(
12  *   id = "d6_imagecache_presets",
13  *   source_provider = "imagecache"
14  * )
15  */
16 class ImageCachePreset extends DrupalSqlBase {
17
18   /**
19    * {@inheritdoc}
20    */
21   public function query() {
22     $query = $this->select('imagecache_preset', 'icp')
23       ->fields('icp');
24     return $query;
25   }
26
27   /**
28    * {@inheritdoc}
29    */
30   public function fields() {
31     $fields = [
32       'presetid' => $this->t('Preset ID'),
33       'presetname' => $this->t('Preset Name'),
34     ];
35     return $fields;
36   }
37
38   /**
39    * {@inheritdoc}
40    */
41   public function getIds() {
42     $ids['presetid']['type'] = 'integer';
43     return $ids;
44   }
45
46   /**
47    * {@inheritdoc}
48    */
49   public function prepareRow(Row $row) {
50     $actions = [];
51
52     $results = $this->select('imagecache_action', 'ica')
53       ->fields('ica')
54       ->condition('presetid', $row->getSourceProperty('presetid'))
55       ->execute();
56
57     foreach ($results as $key => $result) {
58       $actions[$key] = $result;
59       $actions[$key]['data'] = unserialize($result['data']);
60     }
61
62     $row->setSourceProperty('actions', $actions);
63     return parent::prepareRow($row);
64   }
65
66 }