public function XBBCodeFilter::process in Extensible BBCode 4.0.x
Same name and namespace in other branches
- 8.3 src/Plugin/Filter/XBBCodeFilter.php \Drupal\xbbcode\Plugin\Filter\XBBCodeFilter::process()
- 8.2 src/Plugin/Filter/XBBCodeFilter.php \Drupal\xbbcode\Plugin\Filter\XBBCodeFilter::process()
Performs the filter processing.
Parameters
string $text: The text string to be filtered.
string $langcode: The language code of the text to be filtered.
Return value
\Drupal\filter\FilterProcessResult The filtered text, wrapped in a FilterProcessResult object, and possibly with associated assets, cacheability metadata and placeholders.
Overrides FilterInterface::process
See also
\Drupal\filter\FilterProcessResult
File
- src/
Plugin/ Filter/ XBBCodeFilter.php, line 224
Class
- XBBCodeFilter
- Provides a filter that converts BBCode to HTML.
Namespace
Drupal\xbbcode\Plugin\FilterCode
public function process($text, $langcode) : FilterProcessResult {
$tree = $this->parser
->parse($text);
if ($this->settings['xss']) {
static::filterXss($tree);
}
// Reverse any HTML filtering in attribute and option strings.
static::decodeHtml($tree);
// The core AutoP filter breaks inline tags that span multiple paragraphs.
// Since there is no advantage in using <p></p> tags, this filter uses
// ordinary <br /> tags which are usable inside inline tags.
if ($this->settings['linebreaks']) {
static::addLinebreaks($tree);
}
$output = $tree
->render();
$result = new FilterProcessResult($output);
$result
->addCacheTags($this->cacheTags);
foreach ($tree
->getRenderedChildren() as $child) {
if ($child instanceof TagProcessResult) {
$result = $result
->merge($child);
}
}
return $result;
}