PreparedTagElement.php in Extensible BBCode 4.0.x
File
src/PreparedTagElement.php
View source
<?php
namespace Drupal\xbbcode;
use Drupal\Core\Render\Markup;
use Drupal\xbbcode\Parser\Processor\TagProcessorInterface;
use Drupal\xbbcode\Parser\Tree\ElementInterface;
use Drupal\xbbcode\Parser\Tree\NodeElementInterface;
use Drupal\xbbcode\Parser\Tree\OutputElementInterface;
use Drupal\xbbcode\Parser\Tree\TagElementInterface;
class PreparedTagElement implements TagElementInterface {
protected $tag;
protected $outerSource;
public function __construct(TagElementInterface $tag) {
$this->tag = $tag;
}
public function getName() : string {
return $this->tag
->getName();
}
public function getOpeningName() : string {
return $this->tag
->getOpeningName();
}
public function getClosingName() : string {
return $this->tag
->getClosingName();
}
public function setClosingName(string $closing) : TagElementInterface {
return $this->tag
->setClosingName($closing);
}
public function getArgument() : string {
return $this->tag
->getArgument();
}
public function getAttribute(string $name) : ?string {
return $this->tag
->getAttribute($name);
}
public function setAttribute(string $name, string $value = NULL) : void {
$this->tag
->setAttribute($name, $value);
}
public function getAttributes() : array {
return $this->tag
->getAttributes();
}
public function setAttributes(array $attributes) : void {
$this->tag
->setAttributes($attributes);
}
public function getOption() : string {
return $this->tag
->getOption();
}
public function setOption(string $value) : void {
$this->tag
->setOption($value);
}
public function getContent() {
return Markup::create($this->tag
->getContent());
}
public function getSource() {
return Markup::create($this->tag
->getSource());
}
public function setSource(string $source) : void {
$this->tag
->setSource($source);
}
public function getOuterSource() {
if (!isset($this->outerSource)) {
$argument = XssEscape::filterAdmin($this->tag
->getArgument());
$content = $this->tag
->getContent();
$this->outerSource = Markup::create("[{$this->getOpeningName()}{$argument}]{$content}[/{$this->getClosingName()}]");
}
return $this->outerSource;
}
public function getProcessor() : TagProcessorInterface {
return $this->tag
->getProcessor();
}
public function setProcessor(TagProcessorInterface $processor) : void {
$this->tag
->setProcessor($processor);
}
public function render() : OutputElementInterface {
return $this->tag
->render();
}
public function append(ElementInterface $element) : void {
$this->tag
->append($element);
}
public function getChildren() : array {
return $this->tag
->getChildren();
}
public function getRenderedChildren($force_render = TRUE) : array {
return $this->tag
->getRenderedChildren($force_render);
}
public function getDescendants() {
return $this->tag
->getDescendants();
}
public function getParent() : NodeElementInterface {
return $this->tag
->getParent();
}
public function setParent(NodeElementInterface $parent) : void {
$this->tag
->setParent($parent);
}
}