You are here

function js_is_renderable in JS Callback Handler 7.2

Helper function to determine if an array is renderable.

Parameters

array $array: The array to check.

bool $recursive: If TRUE, the entire array (children) is searched, otherwise only the first level is checked.

Return value

bool TRUE if renderable, FALSE if not.

1 call to js_is_renderable()
js_deliver_json in includes/json.inc
Callback for delivering JSON responses to the browser.

File

includes/common.inc, line 112
Common functions used in any JS request.

Code

function js_is_renderable(array $array = array(), $recursive = TRUE) {
  static $keys = array(
    '#type',
    '#theme',
    '#theme_wrappers',
    '#children',
    '#markup',
    '#pre_render',
    '#post_render',
  );
  if (array_intersect($keys, element_properties($array))) {
    return TRUE;
  }
  if ($recursive) {
    foreach (element_children($array) as $child) {
      if (is_array($array[$child]) && js_is_renderable($array[$child])) {
        return TRUE;
      }
    }
  }
  return FALSE;
}