class FilterSettings

Same name and namespace in other branches
  1. 9 core/modules/filter/src/Plugin/migrate/process/FilterSettings.php \Drupal\filter\Plugin\migrate\process\FilterSettings
  2. 8.9.x core/modules/filter/src/Plugin/migrate/process/FilterSettings.php \Drupal\filter\Plugin\migrate\process\FilterSettings
  3. 10 core/modules/filter/src/Plugin/migrate/process/FilterSettings.php \Drupal\filter\Plugin\migrate\process\FilterSettings

Adds the default allowed attributes to filter_html's allowed_html setting.

E.g. map '<a>' to '<a href hreflang dir>'.

Attributes

#[MigrateProcess(id: "filter_settings", handle_multiples: TRUE)]

Hierarchy

Expanded class hierarchy of FilterSettings

1 file declares its use of FilterSettings
FilterSettingsTest.php in core/modules/filter/tests/src/Kernel/Plugin/migrate/process/FilterSettingsTest.php

File

core/modules/filter/src/Plugin/migrate/process/FilterSettings.php, line 15

Namespace

Drupal\filter\Plugin\migrate\process
View source
class FilterSettings extends ProcessPluginBase {
  
  /**
   * Default attributes for migrating filter_html's 'allowed_html' setting.
   *
   * @var string[]
   */
  protected $allowedHtmlDefaultAttributes = [
    '<a>' => '<a href hreflang>',
    '<blockquote>' => '<blockquote cite>',
    '<ol>' => '<ol start type>',
    '<ul>' => '<ul type>',
    '<img>' => '<img src alt height width>',
    '<h2>' => '<h2 id>',
    '<h3>' => '<h3 id>',
    '<h4>' => '<h4 id>',
    '<h5>' => '<h5 id>',
    '<h6>' => '<h6 id>',
  ];
  
  /**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    // Only the filter_html filter's settings have a changed format.
    if ($row->getDestinationProperty('id') === 'filter_html') {
      if (!empty($value['allowed_html'])) {
        $value['allowed_html'] = str_replace(array_keys($this->allowedHtmlDefaultAttributes), array_values($this->allowedHtmlDefaultAttributes), $value['allowed_html']);
      }
    }
    elseif ($row->getDestinationProperty('id') === 'filter_null') {
      $value = [];
    }
    return $value;
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
FilterSettings::$allowedHtmlDefaultAttributes protected property Default attributes for migrating filter_html&#039;s &#039;allowed_html&#039; setting.
FilterSettings::transform public function Performs the associated process. Overrides ProcessPluginBase::transform
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 7
PluginInspectionInterface::getPluginId public function Gets the plugin ID of the plugin instance. 3
ProcessPluginBase::$stopPipeline protected property Determines if processing of the pipeline is stopped.
ProcessPluginBase::isPipelineStopped public function Determines if the pipeline should stop processing. Overrides MigrateProcessInterface::isPipelineStopped
ProcessPluginBase::multiple public function Indicates whether the returned value requires multiple handling. Overrides MigrateProcessInterface::multiple 3
ProcessPluginBase::reset public function Resets the internal data of a plugin. Overrides MigrateProcessInterface::reset
ProcessPluginBase::stopPipeline protected function Stops pipeline processing after this plugin finishes.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.