You are here

protected function Webform::checkElementsFlattenedAccess in Webform 8.5

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

Check operation access for each element.

Parameters

string $operation: (optional) The operation that is to be performed on the element.

array $elements: An associative array of flattened form elements.

Return value

array An associative array of flattened form elements with each element's operation access checked.

3 calls to Webform::checkElementsFlattenedAccess()
Webform::getElementsDecodedAndFlattened in src/Entity/Webform.php
Get webform raw elements decoded and flattened into an associative array.
Webform::getElementsInitializedAndFlattened in src/Entity/Webform.php
Get webform elements initialized and flattened into an associative array.
Webform::getElementsInitializedFlattenedAndHasValue in src/Entity/Webform.php
Get webform flattened list of elements.

File

src/Entity/Webform.php, line 1346

Class

Webform
Defines the webform entity.

Namespace

Drupal\webform\Entity

Code

protected function checkElementsFlattenedAccess($operation = NULL, array $elements = []) {
  if ($operation === NULL) {
    return $elements;
  }

  /** @var \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager */
  $element_manager = \Drupal::service('plugin.manager.webform.element');
  foreach ($elements as $key => $element) {
    $element_plugin = $element_manager
      ->getElementInstance($element, $this);
    if (!$element_plugin
      ->checkAccessRules($operation, $element)) {
      unset($elements[$key]);
    }
  }
  return $elements;
}