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"
15 class FilterFormat extends DrupalSqlBase {
20 public function query() {
21 return $this->select('filter_format', 'f')->fields('f');
27 public function fields() {
29 'format' => $this->t('Format ID.'),
30 'name' => $this->t('The name of the format.'),
31 'cache' => $this->t('Whether the format is cacheable.'),
32 'status' => $this->t('The status of the format'),
33 'weight' => $this->t('The weight of the format'),
34 'filters' => $this->t('The filters configured for the format.'),
41 public function prepareRow(Row $row) {
42 // Find filters for this format.
43 $filters = $this->select('filter', 'f')
45 ->condition('format', $row->getSourceProperty('format'))
46 ->condition('status', 1)
48 ->fetchAllAssoc('name');
50 foreach ($filters as $id => $filter) {
51 $filters[$id]['settings'] = unserialize($filter['settings']);
53 $row->setSourceProperty('filters', $filters);
55 return parent::prepareRow($row);
61 public function getIds() {
62 $ids['format']['type'] = 'string';