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"
15 class FilterFormat extends DrupalSqlBase {
20 public function query() {
21 return $this->select('filter_formats', '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 'roles' => $this->t('The role IDs which can use the format.'),
33 'filters' => $this->t('The filters configured for the format.'),
40 public function prepareRow(Row $row) {
42 $roles = $row->getSourceProperty('roles');
43 $row->setSourceProperty('roles', array_values(array_filter(explode(',', $roles))));
44 $format = $row->getSourceProperty('format');
45 // Find filters for this row.
46 $results = $this->select('filters', 'f')
47 ->fields('f', ['module', 'delta', 'weight'])
48 ->condition('format', $format)
50 foreach ($results as $raw_filter) {
51 $module = $raw_filter['module'];
52 $delta = $raw_filter['delta'];
56 'weight' => $raw_filter['weight'],
59 // Load the filter settings for the filter module, modules can use
60 // hook_migration_d6_filter_formats_prepare_row() to add theirs.
61 if ($raw_filter['module'] == 'filter') {
63 if ($setting = $this->variableGet("allowed_html_$format", NULL)) {
64 $filter['settings']['allowed_html'] = $setting;
66 if ($setting = $this->variableGet("filter_html_help_$format", NULL)) {
67 $filter['settings']['filter_html_help'] = $setting;
69 if ($setting = $this->variableGet("filter_html_nofollow_$format", NULL)) {
70 $filter['settings']['filter_html_nofollow'] = $setting;
73 elseif ($delta == 2 && ($setting = $this->variableGet("filter_url_length_$format", NULL))) {
74 $filter['settings']['filter_url_length'] = $setting;
80 $row->setSourceProperty('filters', $filters);
81 return parent::prepareRow($row);
87 public function getIds() {
88 $ids['format']['type'] = 'integer';