You are here

protected static function ElementTree::applyRecursivelyPreOrder in Little helpers 7.2

Apply a callback recursively in pre-order.

1 call to ElementTree::applyRecursivelyPreOrder()
ElementTree::applyRecursively in src/ElementTree.php
Apply a callback recursively to all elements in a form or renderable array.

File

src/ElementTree.php, line 45

Class

ElementTree
A collection of helper function for element trees.

Namespace

Drupal\little_helpers

Code

protected static function applyRecursivelyPreOrder(array &$element, callable $callback, &$parent = NULL, $key = NULL) {
  $callback($element, $key, $parent);
  foreach (element_children($element) as $child_key) {
    static::applyRecursivelyPreOrder($element[$child_key], $callback, $element, $child_key);
  }
}