You are here

public function RenderTagPlugin::doProcess in Extensible BBCode 8.3

Same name and namespace in other branches
  1. 4.0.x src/Plugin/RenderTagPlugin.php \Drupal\xbbcode\Plugin\RenderTagPlugin::doProcess()

Create the actual output.

Tag plugins should override this function rather than ::process(), in order to let the metadata from sub-tags bubble up.

Parameters

\Drupal\xbbcode\Parser\Tree\TagElementInterface $tag: Tag element in the parse tree.

Return value

\Drupal\xbbcode\TagProcessResult Tag process result.

Overrides TagPluginBase::doProcess

File

src/Plugin/RenderTagPlugin.php, line 73

Class

RenderTagPlugin
Base class for plugins that produce a Drupal render array.

Namespace

Drupal\xbbcode\Plugin

Code

public function doProcess(TagElementInterface $tag) : TagProcessResult {
  $element = $this
    ->buildElement($tag);

  // Use a new render context; metadata bubbles through the filter result.
  // Importantly, this adds language and theme cache contexts, just in
  // case the filter is used in an otherwise theme-independent context.
  $output = $this->renderer
    ->renderPlain($element);
  $result = TagProcessResult::createFromRenderArray($element);
  $result
    ->setProcessedText((string) $output);
  return $result;
}