3 namespace Drupal\filter\Plugin\migrate\source\d7;
5 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
6 use Drupal\migrate\Row;
9 * Drupal 7 filter source from database.
12 * id = "d7_filter_format",
13 * source_module = "filter"
16 class FilterFormat extends DrupalSqlBase {
21 public function query() {
22 return $this->select('filter_format', 'f')->fields('f');
28 public function fields() {
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.'),
42 public function prepareRow(Row $row) {
43 // Find filters for this format.
44 $filters = $this->select('filter', 'f')
46 ->condition('format', $row->getSourceProperty('format'))
47 ->condition('status', 1)
49 ->fetchAllAssoc('name');
51 foreach ($filters as $id => $filter) {
52 $filters[$id]['settings'] = unserialize($filter['settings']);
54 $row->setSourceProperty('filters', $filters);
56 return parent::prepareRow($row);
62 public function getIds() {
63 $ids['format']['type'] = 'string';