devel_themer_catch_function()Intercepts all theme calls (including templates), adds to template log, and dispatches to original theme function. This function gets injected into theme registry in devel_exit().
sites/all/modules/devel/devel_themer.module, line 216
<?php
function devel_themer_catch_function() {
$args = func_get_args();
// Get the function that is normally called.
$trace = debug_backtrace();
$hook = $trace[2]['args'][0];
array_unshift($args, $hook);
$counter = devel_counter();
$timer_name = "thmr_$counter";
timer_start($timer_name);
// The twin of theme(). All rendering done through here.
list($return, $meta) = call_user_func_array('devel_themer_theme_twin', $args);
$time = timer_stop($timer_name);
$skip_calls = array('hidden', 'form_element', 'placeholder');
if (!empty($return) && !is_array($return) && !is_object($return) && user_access('access devel information')) {
list($prefix, $suffix) = devel_theme_call_marker($hook, $counter, 'func');
$start_return = substr($return, 0, 31);
$start_prefix = substr($prefix, 0, 31);
if ($start_return != $start_prefix && !in_array($hook, $skip_calls) && empty($GLOBALS['devel_themer_stop'])) {
if ($hook == 'page') {
$GLOBALS['devel_theme_calls']['page_id'] = $counter;
// Stop logging theme calls after we see theme('page'). This prevents
// needless logging of devel module's query log, for example. Other modules may set this global as needed.
$GLOBALS['devel_themer_stop'] = TRUE;
}
else {
$output = $prefix. "\n ". $return. $suffix. "\n";
}
if ($meta['type'] == 'func') {
$name = $meta['used'];
$used = $meta['used'];
if (empty($meta['wildcards'])) {
$meta['wildcards'][$hook] = '';
}
$candidates = devel_themer_ancestry(array_reverse(array_keys($meta['wildcards'])));
if (empty($meta['variables'])) {
$variables = array();
}
}
else {
$name = $meta['used']. devel_themer_get_extension();
if (empty($suggestions)) {
array_unshift($meta['suggestions'], $meta['used']);
}
$candidates = array_reverse(array_map('devel_themer_append_extension', $meta['suggestions']));
$used = $meta['template_file'];
}
$key = "thmr_$counter";
// This variable gets sent to the browser in Drupal.settings.
$GLOBALS['devel_theme_calls'][$key] = array(
'name' => $name,
'type' => $meta['type'],
'duration' => $time['time'],
'used' => $used,
'candidates' => $candidates,
'preprocessors' => isset($meta['preprocessors']) ? $meta['preprocessors'] : array(),
);
// This variable gets serialized and cached on the server.
$GLOBALS['devel_themer_server'][$key] = array(
'variables' => $meta['variables'],
'type' => $meta['type'],
);
}
else {
$output = $return;
}
}
return isset($output) ? $output : $return;
}
?>