3 namespace Drupal\filter\Plugin\migrate\process;
5 use Drupal\migrate\ProcessPluginBase;
6 use Drupal\migrate\MigrateExecutableInterface;
7 use Drupal\migrate\Row;
10 * Adds the default allowed attributes to filter_html's allowed_html setting.
12 * E.g. map '<a>' to '<a href hreflang dir>'.
14 * @MigrateProcessPlugin(
15 * id = "filter_settings",
16 * handle_multiples = TRUE
19 class FilterSettings extends ProcessPluginBase {
22 * Default attributes for migrating filter_html's 'allowed_html' setting.
26 protected $allowedHtmlDefaultAttributes = [
27 '<a>' => '<a href hreflang>',
28 '<blockquote>' => '<blockquote cite>',
29 '<ol>' => '<ol start type>',
30 '<ul>' => '<ul type>',
31 '<img>' => '<img src alt height width>',
42 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
43 // Only the filter_html filter's settings have a changed format.
44 if ($row->getDestinationProperty('id') === 'filter_html') {
45 if (!empty($value['allowed_html'])) {
46 $value['allowed_html'] = str_replace(array_keys($this->allowedHtmlDefaultAttributes), array_values($this->allowedHtmlDefaultAttributes), $value['allowed_html']);