You are here

protected function Webform::setElementPropertiesRecursive in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Entity/Webform.php \Drupal\webform\Entity\Webform::setElementPropertiesRecursive()

Set element properties.

Parameters

array $elements: An associative nested array of elements.

string $key: The element's key.

array $properties: An associative array of properties.

string $parent_key: (optional) The element's parent key. Only used for new elements.

Return value

bool TRUE when the element's properties has been set. FALSE when the element has not been found.

1 call to Webform::setElementPropertiesRecursive()
Webform::setElementProperties in src/Entity/Webform.php
Set element properties.

File

src/Entity/Webform.php, line 1900

Class

Webform
Defines the webform entity.

Namespace

Drupal\webform\Entity

Code

protected function setElementPropertiesRecursive(array &$elements, $key, array $properties, $parent_key = '') {
  foreach ($elements as $element_key => &$element) {

    // Make sure the element key is a string.
    $element_key = (string) $element_key;
    if (!WebformElementHelper::isElement($element, $element_key)) {
      continue;
    }
    if ($element_key === $key) {
      $element = $properties + WebformElementHelper::removeProperties($element);
      return TRUE;
    }
    if ($element_key === $parent_key) {
      $element[$key] = $properties;
      return TRUE;
    }
    if ($this
      ->setElementPropertiesRecursive($element, $key, $properties, $parent_key)) {
      return TRUE;
    }
  }
  return FALSE;
}