public static function XBBCodeFilter::doPrepare in Extensible BBCode 8.3
Same name and namespace in other branches
- 4.0.x src/Plugin/Filter/XBBCodeFilter.php \Drupal\xbbcode\Plugin\Filter\XBBCodeFilter::doPrepare()
Recursively apply source transformations to each tag element.
Parameters
\Drupal\xbbcode\Parser\Tree\ElementInterface $node: The parse tree.
Return value
string The fully prepared source.
1 call to XBBCodeFilter::doPrepare()
- XBBCodeFilter::prepare in src/
Plugin/ Filter/ XBBCodeFilter.php - Prepares the text for processing.
File
- src/
Plugin/ Filter/ XBBCodeFilter.php, line 262
Class
- XBBCodeFilter
- Provides a filter that converts BBCode to HTML.
Namespace
Drupal\xbbcode\Plugin\FilterCode
public static function doPrepare(ElementInterface $node) : string {
if ($node instanceof NodeElementInterface) {
$content = [];
foreach ($node
->getChildren() as $child) {
$content[] = static::doPrepare($child);
}
$content = implode('', $content);
if ($node instanceof TagElementInterface) {
$name = $node
->getName();
$processor = $node
->getProcessor();
if ($processor instanceof TagPluginInterface) {
$content = $processor
->prepare($content, $node);
}
return "[{$name}{$node->getArgument()}]{$content}[/{$name}]";
}
return $content;
}
return $node
->render();
}