You are here

protected function OptionsLimitWebformHandler::removeOptionsElementRecursive in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_options_limit/src/Plugin/WebformHandler/OptionsLimitWebformHandler.php \Drupal\webform_options_limit\Plugin\WebformHandler\OptionsLimitWebformHandler::removeOptionsElementRecursive()

Remove options element's reached options.

Parameters

array $options: An array options (and optgroups).

array $reached: An options element's reached options.

1 call to OptionsLimitWebformHandler::removeOptionsElementRecursive()
OptionsLimitWebformHandler::removeOptionsElement in modules/webform_options_limit/src/Plugin/WebformHandler/OptionsLimitWebformHandler.php
Remove options element's reached options.

File

modules/webform_options_limit/src/Plugin/WebformHandler/OptionsLimitWebformHandler.php, line 742

Class

OptionsLimitWebformHandler
Webform options and boolean (boolean) limit handler.

Namespace

Drupal\webform_options_limit\Plugin\WebformHandler

Code

protected function removeOptionsElementRecursive(array &$options, array $reached) {
  foreach ($options as $option_value => &$option_text) {
    if (is_array($option_text)) {
      $this
        ->removeOptionsElementRecursive($option_text, $reached);
      if (empty($option_text)) {
        unset($options[$option_value]);
      }
    }
    elseif (isset($reached[$option_value])) {
      unset($options[$option_value]);
    }
  }
}