Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / filter / src / Plugin / migrate / source / d7 / FilterFormat.php
1 <?php
2
3 namespace Drupal\filter\Plugin\migrate\source\d7;
4
5 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
6 use Drupal\migrate\Row;
7
8 /**
9  * Drupal 7 filter source from database.
10  *
11  * @MigrateSource(
12  *   id = "d7_filter_format",
13  *   source_module = "filter"
14  * )
15  */
16 class FilterFormat extends DrupalSqlBase {
17
18   /**
19    * {@inheritdoc}
20    */
21   public function query() {
22     return $this->select('filter_format', 'f')->fields('f');
23   }
24
25   /**
26    * {@inheritdoc}
27    */
28   public function fields() {
29     return [
30       'format' => $this->t('Format ID.'),
31       'name' => $this->t('The name of the format.'),
32       'cache' => $this->t('Whether the format is cacheable.'),
33       'status' => $this->t('The status of the format'),
34       'weight' => $this->t('The weight of the format'),
35       'filters' => $this->t('The filters configured for the format.'),
36     ];
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function prepareRow(Row $row) {
43     // Find filters for this format.
44     $filters = $this->select('filter', 'f')
45       ->fields('f')
46       ->condition('format', $row->getSourceProperty('format'))
47       ->condition('status', 1)
48       ->execute()
49       ->fetchAllAssoc('name');
50
51     foreach ($filters as $id => $filter) {
52       $filters[$id]['settings'] = unserialize($filter['settings']);
53     }
54     $row->setSourceProperty('filters', $filters);
55
56     return parent::prepareRow($row);
57   }
58
59   /**
60    * {@inheritdoc}
61    */
62   public function getIds() {
63     $ids['format']['type'] = 'string';
64     return $ids;
65   }
66
67 }