You are here

public function EntityTagPlugin::getTemplate in Extensible BBCode 4.0.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/XBBCode/EntityTagPlugin.php \Drupal\xbbcode\Plugin\XBBCode\EntityTagPlugin::getTemplate()

Get the tag template.

Return value

\Twig_TemplateWrapper The compiled template that should render this tag.

Throws

\Twig\Error\LoaderError

\Twig\Error\RuntimeError

\Twig\Error\SyntaxError

Overrides TemplateTagPlugin::getTemplate

File

src/Plugin/XBBCode/EntityTagPlugin.php, line 93

Class

EntityTagPlugin
A tag plugin based on a custom tag entity.

Namespace

Drupal\xbbcode\Plugin\XBBCode

Code

public function getTemplate() : TwigTemplateWrapper {

  // Lazily prepare the template, if it does not exist yet.
  if ($this->template === NULL) {
    $entity = $this
      ->getEntity();
    $code = $entity
      ->getTemplateCode();
    $file = $entity
      ->getTemplateFile();
    $this->template = $file && !$code ? $file : self::TEMPLATE_PREFIX . $code;
  }

  // Delegate template-loading to the parent.
  return parent::getTemplate();
}