You are here

public static function XBBCodeParser::decorateTree in Extensible BBCode 4.0.x

Same name and namespace in other branches
  1. 8.3 src/Parser/XBBCodeParser.php \Drupal\xbbcode\Parser\XBBCodeParser::decorateTree()

Assign processors to the tag elements of a tree.

Parameters

\Drupal\xbbcode\Parser\Tree\NodeElementInterface $node: The tree to decorate.

\Drupal\xbbcode\Parser\Processor\TagProcessorInterface[]|\ArrayAccess $processors: The processors, keyed by name.

1 call to XBBCodeParser::decorateTree()
XBBCodeParser::parse in src/Parser/XBBCodeParser.php
Parse a text and build an element tree.

File

src/Parser/XBBCodeParser.php, line 286

Class

XBBCodeParser
The standard XBBCode parser.

Namespace

Drupal\xbbcode\Parser

Code

public static function decorateTree(NodeElementInterface $node, $processors) : void {
  foreach ($node
    ->getChildren() as $child) {
    if ($child instanceof TagElementInterface) {
      $child
        ->setParent($node);
      if ($processor = $processors[$child
        ->getName()]) {
        $child
          ->setProcessor($processor);
      }
      static::decorateTree($child, $processors);
    }
  }
}