You are here

protected static function ElementTree::applyRecursivelyPostOrder in Little helpers 7.2

Apply a callback recursively in post-order.

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

File

src/ElementTree.php, line 55

Class

ElementTree
A collection of helper function for element trees.

Namespace

Drupal\little_helpers

Code

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