You are here

function rules_admin_rule_proxy::_clean_rule in Rules 6

1 call to rules_admin_rule_proxy::_clean_rule()
rules_admin_rule_proxy::clean_rule in rules_admin/rules_admin.rule_proxy.inc
Cleans the given rule. This means, array keys that are neither elements nor properties are removed.

File

rules_admin/rules_admin.rule_proxy.inc, line 178
Contains the rules proxy class

Class

rules_admin_rule_proxy
This is a smally proxy for the real rule. It provides some useful operations for the admin UI. It builds a small index for the elements of a rule, so that they can be easily identified and modified.

Code

function _clean_rule(&$element) {
  $children = array();
  foreach (element_children($element) as $key) {
    if (!isset($element[$key]['#type'])) {

      //this element can be removed, but care for it's children
      foreach (element_children($element[$key]) as $child_key) {
        $children[$child_key] = $element[$key][$child_key];
      }
      unset($element[$key]);
    }
    else {
      $this
        ->_clean_rule($element[$key]);
    }
  }
  if (count($children)) {
    $element = array_merge($element, $children);
  }
}