You are here

public function Element::appendProperty in Express 8

Appends a property with a value.

Parameters

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

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

Return value

$this

File

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

Class

Element
Provides helper methods for Drupal render elements.

Namespace

Drupal\bootstrap\Utility

Code

public function appendProperty($name, $value) {
  $property =& $this
    ->getProperty($name);
  $value = $value instanceof Element ? $value
    ->getArray() : $value;

  // If property isn't set, just set it.
  if (!isset($property)) {
    $property = $value;
    return $this;
  }
  if (is_array($property)) {
    $property[] = Element::create($value)
      ->getArray();
  }
  else {
    $property .= (string) $value;
  }
  return $this;
}