You are here

private static function WebformValidateConstraint::getFormElementAccess in Webform Validation 8

Same name and namespace in other branches
  1. 2.0.x src/Validate/WebformValidateConstraint.php \Drupal\webform_validation\Validate\WebformValidateConstraint::getFormElementAccess()

Check Element Access.

Parameters

array $elements: The form elements.

string $searchKey: Key of the equal component.

bool $found: The key.

array $element: Result array.

3 calls to WebformValidateConstraint::getFormElementAccess()
WebformValidateConstraint::validateFrontCompareComponent in src/Validate/WebformValidateConstraint.php
Validates compare fields.
WebformValidateConstraint::validateFrontEqualComponent in src/Validate/WebformValidateConstraint.php
Validates Equal components on front end.
WebformValidateConstraint::validateFrontSomeSeveralComponent in src/Validate/WebformValidateConstraint.php
Validates Some of Several in fields.

File

src/Validate/WebformValidateConstraint.php, line 403

Class

WebformValidateConstraint
Form API callback. Validate element value.

Namespace

Drupal\webform_validation\Validate

Code

private static function getFormElementAccess(array &$elements, string $searchKey, bool &$found, array &$element) : void {
  if (!$found) {
    $element['access'] = $element['multiple'] = FALSE;
    foreach ($elements as $keyElement => &$keyValue) {
      if (!WebformElementHelper::isElement($keyValue, $keyElement)) {
        continue;
      }
      if (!empty($keyElement) && $keyElement == $searchKey) {
        $found = TRUE;
        $element = $keyValue;
        if (!empty($keyValue['#access']) || !empty($keyValue['#visited'])) {
          $element['access'] = TRUE;
        }
        if (!empty($keyValue['#webform_multiple'])) {
          $element['multiple'] = TRUE;
        }
      }
      elseif (!$found) {
        self::getFormElementAccess($keyValue, $searchKey, $found, $element);
      }
    }
  }
}