FilterTestReplace.php

Same filename in other branches
  1. 9 core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestReplace.php
  2. 10 core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestReplace.php
  3. 11.x core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestReplace.php

Namespace

Drupal\filter_test\Plugin\Filter

File

core/modules/filter/tests/filter_test/src/Plugin/Filter/FilterTestReplace.php

View source
<?php

namespace Drupal\filter_test\Plugin\Filter;

use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;

/**
 * Provides a test filter to replace all content.
 *
 * @Filter(
 *   id = "filter_test_replace",
 *   title = @Translation("Testing filter"),
 *   description = @Translation("Replaces all content with filter and text format information."),
 *   type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE
 * )
 */
class FilterTestReplace extends FilterBase {
    
    /**
     * {@inheritdoc}
     */
    public function process($text, $langcode) {
        $text = [];
        $text[] = 'Filter: ' . $this->getLabel() . ' (' . $this->getPluginId() . ')';
        $text[] = 'Language: ' . $langcode;
        return new FilterProcessResult(implode("<br />\n", $text));
    }

}

Classes

Title Deprecated Summary
FilterTestReplace Provides a test filter to replace all content.

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