You are here

function _webform_components_tree_flatten in Webform 5

Same name and namespace in other branches
  1. 5.2 webform.module \_webform_components_tree_flatten()
  2. 6.3 webform.module \_webform_components_tree_flatten()
  3. 6.2 webform.module \_webform_components_tree_flatten()
  4. 7.4 webform.module \_webform_components_tree_flatten()
  5. 7.3 webform.module \_webform_components_tree_flatten()

Flatten a component tree into a flat list.

1 call to _webform_components_tree_flatten()
webform_load in ./webform.module
Implemenation of hook_load().

File

./webform.module, line 1915

Code

function _webform_components_tree_flatten($tree) {
  $components = array();
  foreach ($tree as $cid => $component) {
    if (isset($component['children'])) {
      unset($component['children']);
      $components[$cid] = $component;

      // array_merge() can't be used here because the keys are numeric.
      $children = _webform_components_tree_flatten($tree[$cid]['children']);
      foreach ($children as $ccid => $ccomponent) {
        $components[$ccid] = $ccomponent;
      }
    }
    else {
      $components[$cid] = $component;
    }
  }
  return $components;
}