You are here

public function Element::__set in Express 8

Magic set method.

This is only for child elements, not properties.

Parameters

string $key: The name of the child element to set.

mixed $value: The value of $name to set.

Throws

\InvalidArgumentException Throws this error when the name is a property (key starting with #).

Overrides ArrayObject::__set

File

themes/contrib/bootstrap/src/Utility/Element.php, line 94
Contains \Drupal\bootstrap\Utility\Element.

Class

Element
Provides helper methods for Drupal render elements.

Namespace

Drupal\bootstrap\Utility

Code

public function __set($key, $value) {
  if (\Drupal\Core\Render\Element::property($key)) {
    throw new \InvalidArgumentException('Cannot dynamically retrieve element property. Use \\Drupal\\bootstrap\\Utility\\Element::setProperty instead.');
  }
  $this
    ->offsetSet($key, $value instanceof Element ? $value
    ->getArray() : $value);
}