You are here

public static function WebformElementHelper::hasProperties in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Utility/WebformElementHelper.php \Drupal\webform\Utility\WebformElementHelper::hasProperties()

Determine if element or sub-element has properties.

Parameters

array $element: An element.

array $properties: Element properties.

Return value

bool TRUE if element or sub-element has any property.

2 calls to WebformElementHelper::hasProperties()
WebformElementHelper::hasProperty in src/Utility/WebformElementHelper.php
Determine if element or sub-element has property and value.
WebformMultiple::hasRequireElement in src/Element/WebformMultiple.php
Determine if any sub-element is required.

File

src/Utility/WebformElementHelper.php, line 230

Class

WebformElementHelper
Helper class webform element methods.

Namespace

Drupal\webform\Utility

Code

public static function hasProperties(array $element, array $properties) {
  foreach ($element as $key => $value) {

    // Recurse through sub-elements.
    if (static::isElement($value, $key)) {
      if (static::hasProperties($value, $properties)) {
        return TRUE;
      }
    }
    elseif (array_key_exists($key, $properties) && ($properties[$key] === NULL || $properties[$key] === $value)) {
      return TRUE;
    }
  }
  return FALSE;
}