function public function Element::setProperty

8.x-3.x Element.php public Element::setProperty($name, $value, $recurse = FALSE)

Sets the value for a property.

Parameters

string $name: The name of the property to set.

mixed $value: The value of the property to set.

bool $recurse: Flag indicating wither to set the same property on child elements.

Return value

static

Class

Element
Provides helper methods for Drupal render elements.

Namespace

Drupal\bootstrap\Utility

Source src/Utility/Element.php (line 736)

public function setProperty($name, $value, $recurse = FALSE) {
  $this->array["#$name"] = $value instanceof Element ? $value->getArray() : $value;
  if ($recurse) {
    foreach ($this->children() as $child) {
      $child->setProperty($name, $value, $recurse);
    }
  }
  return $this;
}