Same filename and directory in other branches
- 8.9.x core/modules/filter/src/Plugin/migrate/process/FilterID.php
- 9 core/modules/filter/src/Plugin/migrate/process/FilterID.php
Namespace
Drupal\filter\Plugin\migrate\process
File
core/modules/filter/src/Plugin/migrate/process/FilterID.php
View source
<?php
namespace Drupal\filter\Plugin\migrate\process;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\filter\Plugin\FilterInterface;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Plugin\migrate\process\StaticMap;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FilterID extends StaticMap implements ContainerFactoryPluginInterface {
protected $filterManager;
public function __construct(array $configuration, $plugin_id, $plugin_definition, PluginManagerInterface $filter_manager, TranslationInterface $translator = NULL) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->filterManager = $filter_manager;
$this->stringTranslation = $translator;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('plugin.manager.filter'), $container
->get('string_translation'));
}
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$plugin_id = parent::transform($value, $migrate_executable, $row, $destination_property);
if (is_array($plugin_id)) {
$plugin_id = implode(':', $plugin_id);
}
if ($this->filterManager
->hasDefinition($plugin_id)) {
return $plugin_id;
}
else {
if (in_array(static::getSourceFilterType($value), [
FilterInterface::TYPE_TRANSFORM_REVERSIBLE,
FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE,
], TRUE)) {
$message = sprintf('Filter %s could not be mapped to an existing filter plugin; omitted since it is a transformation-only filter. Install and configure a successor after the migration.', $plugin_id);
$migrate_executable
->saveMessage($message, MigrationInterface::MESSAGE_INFORMATIONAL);
$this
->stopPipeline();
return NULL;
}
$fallback = $this->filterManager
->getFallbackPluginId($plugin_id);
$message = sprintf('Filter %s could not be mapped to an existing filter plugin; defaulting to %s and dropping all settings. Either redo the migration with the module installed that provides an equivalent filter, or modify the text format after the migration to remove this filter if it is no longer necessary.', $plugin_id, $fallback);
$migrate_executable
->saveMessage($message, MigrationInterface::MESSAGE_WARNING);
return $fallback;
}
}
protected static function getSourceFilterType($filter_id) {
switch ($filter_id) {
case 'filter_html':
return FilterInterface::TYPE_HTML_RESTRICTOR;
case 'filter_url':
return FilterInterface::TYPE_MARKUP_LANGUAGE;
case 'filter_autop':
return FilterInterface::TYPE_MARKUP_LANGUAGE;
case 'filter_htmlcorrector':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_html_escape':
return FilterInterface::TYPE_HTML_RESTRICTOR;
case 'php_code':
return FilterInterface::TYPE_MARKUP_LANGUAGE;
case 'abbrfilter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'ace_editor':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'adsense':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'api_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'api_tokens':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_autofloat':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'bbcode':
return FilterInterface::TYPE_MARKUP_LANGUAGE;
case 'biblio_filter_reference':
case 'biblio_filter_inline_reference':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'caption':
return FilterInterface::TYPE_TRANSFORM_REVERSIBLE;
case 'caption_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_cincopa':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'ckeditor_blocks':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'ckeditor_filter':
return FilterInterface::TYPE_HTML_RESTRICTOR;
case 'ckeditor_link_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'ckeditor_swf_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'codefilter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'collapse_text_filter':
return FilterInterface::TYPE_TRANSFORM_REVERSIBLE;
case 'columns_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'commonmark':
return FilterInterface::TYPE_MARKUP_LANGUAGE;
case 'filter_hashtags':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'deepzoom':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'editor_align':
case 'editor_caption':
return FilterInterface::TYPE_TRANSFORM_REVERSIBLE;
case 'elf':
return FilterInterface::TYPE_TRANSFORM_REVERSIBLE;
case 'filter_emogrifier':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'emptyparagraphkiller':
return FilterInterface::TYPE_HTML_RESTRICTOR;
case 'entity_embed':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_align':
return FilterInterface::TYPE_TRANSFORM_REVERSIBLE;
case 'ext_link_page':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_html_image_secure':
return FilterInterface::TYPE_HTML_RESTRICTOR;
case 'filter_transliteration':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'flickr_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'float_filter':
return FilterInterface::TYPE_TRANSFORM_REVERSIBLE;
case 'filter_footnotes':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'forena_report':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_g2':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'geo_filter_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_google_analytics_counter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_google_analytics_referrer':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'gotwo_link':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'h5p_content':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'highlight_js':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'htmLawed':
return FilterInterface::TYPE_HTML_RESTRICTOR;
case 'htmlpurifier_basic':
case 'htmlpurifier_advanced':
return FilterInterface::TYPE_HTML_RESTRICTOR;
case 'htmltidy':
return FilterInterface::TYPE_HTML_RESTRICTOR;
case 'icon_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'iframe':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'image_resize_filter':
return FilterInterface::TYPE_TRANSFORM_REVERSIBLE;
case 'insert_view':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'intlinks title':
case 'intlinks hide bad':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'accordion':
case 'dialog':
case 'tabs':
return FilterInterface::TYPE_MARKUP_LANGUAGE;
case 'language_sections':
return FilterInterface::TYPE_MARKUP_LANGUAGE;
case 'lazy_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'lazyloader_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_link_node':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'linktitle':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_markdown':
return FilterInterface::TYPE_MARKUP_LANGUAGE;
case 'media_filter':
case 'media_filter_paragraph_fix':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_mentions':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'menu_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'mobile_codes':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'multicolumn':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'multilink_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'mytube':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'node_embed':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'node_field_embed':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'external_links':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'noreferrer':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'oembed':
case 'oembed_legacy':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'office_html_strip':
return FilterInterface::TYPE_HTML_RESTRICTOR;
case 'office_html_convert':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'openlayers':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'opengraph_filter':
return FilterInterface::TYPE_TRANSFORM_REVERSIBLE;
case 'pathologic':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'popup_tags':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'prettify':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'rel_to_abs':
return FilterInterface::TYPE_TRANSFORM_REVERSIBLE;
case 'rollover_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'sanitizable':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'smart_paging_filter':
case 'smart_paging_filter_autop':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'spamspan':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'mee_scald_widgets':
return FilterInterface::TYPE_TRANSFORM_REVERSIBLE;
case 'script_filter':
return FilterInterface::TYPE_TRANSFORM_REVERSIBLE;
case 'shortcode':
return FilterInterface::TYPE_MARKUP_LANGUAGE;
case 'shortcode_text_corrector':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'smiley':
return FilterInterface::TYPE_TRANSFORM_REVERSIBLE;
case 'filter_svg_embed':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'spoiler':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_toc':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_tables':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'target_filter_url':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'textile':
return FilterInterface::TYPE_MARKUP_LANGUAGE;
case 'theme_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'filter_tokens':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'transliteration':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'typogrify':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'uuid_link_filter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'wysiwyg':
case 'wysiwyg_template_cleanup':
return FilterInterface::TYPE_HTML_RESTRICTOR;
case 'word_link':
return FilterInterface::TYPE_TRANSFORM_REVERSIBLE;
case 'wordfilter':
return FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE;
case 'xbbcode':
return FilterInterface::TYPE_MARKUP_LANGUAGE;
}
return NULL;
}
}
Classes
Name |
Description |
FilterID |
Plugin annotation
@MigrateProcessPlugin(
id = "filter_id"
) |