You are here

public function Element::prependProperty in Express 8

Prepends 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 505
Contains \Drupal\bootstrap\Utility\Element.

Class

Element
Provides helper methods for Drupal render elements.

Namespace

Drupal\bootstrap\Utility

Code

public function prependProperty($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)) {
    array_unshift($property, Element::create($value)
      ->getArray());
  }
  else {
    $property = (string) $value . (string) $property;
  }
  return $this;
}