You are here

public static function YamlFormElementHelper::merge in YAML Form 8

Merge element properties.

Parameters

array $elements: An array of elements.

array $source_elements: An array of elements to be merged.

3 calls to YamlFormElementHelper::merge()
YamlFormElementHelper::applyTranslation in src/Utility/YamlFormElementHelper.php
Apply translation to element.
YamlFormTranslationManager::getTranslationElements in src/YamlFormTranslationManager.php
Get flattened associative array of translated element properties.
_yamlform_form_config_translate_add_form_validate in includes/yamlform.translation.inc
Validate callback; Validates and cleanups form elements.

File

src/Utility/YamlFormElementHelper.php, line 210

Class

YamlFormElementHelper
Helper class form element methods.

Namespace

Drupal\yamlform\Utility

Code

public static function merge(array &$elements, array $source_elements) {
  foreach ($elements as $key => &$element) {
    if (!isset($source_elements[$key])) {
      continue;
    }
    $source_element = $source_elements[$key];
    if (gettype($element) !== gettype($source_element)) {
      continue;
    }
    if (is_array($element)) {
      self::merge($element, $source_element);
    }
    elseif (is_scalar($element)) {
      $elements[$key] = $source_element;
    }
  }
}