3 namespace Drupal\filter\Plugin\migrate\source\d6;
5 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
6 use Drupal\migrate\Row;
9 * Drupal 6 filter source from database.
12 * id = "d6_filter_format",
13 * source_module = "filter"
16 class FilterFormat extends DrupalSqlBase {
21 public function query() {
22 return $this->select('filter_formats', '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 'roles' => $this->t('The role IDs which can use the format.'),
34 'filters' => $this->t('The filters configured for the format.'),
41 public function prepareRow(Row $row) {
43 $roles = $row->getSourceProperty('roles');
44 $row->setSourceProperty('roles', array_values(array_filter(explode(',', $roles))));
45 $format = $row->getSourceProperty('format');
46 // Find filters for this row.
47 $results = $this->select('filters', 'f')
48 ->fields('f', ['module', 'delta', 'weight'])
49 ->condition('format', $format)
51 foreach ($results as $raw_filter) {
52 $module = $raw_filter['module'];
53 $delta = $raw_filter['delta'];
57 'weight' => $raw_filter['weight'],
60 // Load the filter settings for the filter module, modules can use
61 // hook_migration_d6_filter_formats_prepare_row() to add theirs.
62 if ($raw_filter['module'] == 'filter') {
64 if ($setting = $this->variableGet("allowed_html_$format", NULL)) {
65 $filter['settings']['allowed_html'] = $setting;
67 if ($setting = $this->variableGet("filter_html_help_$format", NULL)) {
68 $filter['settings']['filter_html_help'] = $setting;
70 if ($setting = $this->variableGet("filter_html_nofollow_$format", NULL)) {
71 $filter['settings']['filter_html_nofollow'] = $setting;
74 elseif ($delta == 2 && ($setting = $this->variableGet("filter_url_length_$format", NULL))) {
75 $filter['settings']['filter_url_length'] = $setting;
81 $row->setSourceProperty('filters', $filters);
82 return parent::prepareRow($row);
88 public function getIds() {
89 $ids['format']['type'] = 'integer';