You are here

function _webform_update_elements_clear_properties in Webform 6.x

Same name and namespace in other branches
  1. 8.5 includes/webform.install.inc \_webform_update_elements_clear_properties()

Clear/remove selected webform element properties.

Parameters

array $properties: An associative array of webform element properties.

3 calls to _webform_update_elements_clear_properties()
webform_update_8116 in includes/webform.install.update.inc
Stop #multiple__label and #multiple__labels from being saved with every element.
webform_update_8200 in includes/webform.install.update.inc
Issue #3161787: Image select element is included empty filter properties.
webform_update_8609 in includes/webform.install.update.inc
Issue #3161787: Image select element is included empty filter properties.

File

includes/webform.install.inc, line 397
Webform install helper functions.

Code

function _webform_update_elements_clear_properties(array $properties) {
  $pattern = '/(?:' . implode('|', array_keys($properties)) . ')/';
  $config_factory = \Drupal::configFactory();
  foreach ($config_factory
    ->listAll('webform.webform.') as $webform_config_name) {
    $webform_config = $config_factory
      ->getEditable($webform_config_name);
    $data = $webform_config
      ->getRawData();

    // Make sure elements contains the properties.
    if (!preg_match($pattern, $data['elements'])) {
      continue;
    }
    $elements = Yaml::decode($data['elements']);
    _webform_update_elements_clear_properties_recursive($elements, $properties);
    $data['elements'] = Yaml::encode($elements);
    $webform_config
      ->setData($data);
    $webform_config
      ->save();
  }
}