You are here

public function TagElement::setAttribute in Extensible BBCode 4.0.x

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

Set an attribute of the element.

Parameters

string $name: The name of the attribute.

string|null $value: (Optional) The value of the attribute, or NULL to unset it.

Overrides TagElementInterface::setAttribute

File

src/Parser/Tree/TagElement.php, line 146

Class

TagElement
A BBCode tag element.

Namespace

Drupal\xbbcode\Parser\Tree

Code

public function setAttribute(string $name, string $value = NULL) : void {
  $this->attributes[$name] = $value;
  if ($value === NULL) {
    unset($this->attributes[$name]);
  }
}