Builds the content and subject for a block.
For cacheable blocks, this is called during #pre_render.
$element: A renderable array.
A renderable array.
function _block_get_renderable_block($element) {
$block = $element['#block'];
// Render the block content if it has not been created already.
if (!isset($block->content)) {
$array = module_invoke($block->module, 'block_view', $block->delta);
// Allow modules to modify the block before it is viewed, via either
// hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter().
drupal_alter(array(
'block_view',
"block_view_{$block->module}_{$block->delta}",
), $array, $block);
if (empty($array['content'])) {
// Blocks without content should emit no markup at all.
$element += array(
'#access' => FALSE,
'#printed' => TRUE,
);
}
elseif (isset($array) && is_array($array)) {
foreach ($array as $k => $v) {
$block->{$k} = $v;
}
}
}
if (isset($block->content) && $block->content) {
// Normalize to the drupal_render() structure.
if (is_string($block->content)) {
$block->content = array(
'#markup' => $block->content,
);
}
// Override default block title if a custom display title is present.
if ($block->title) {
// Check plain here to allow module generated titles to keep any
// markup.
$block->subject = $block->title == '<none>' ? '' : check_plain($block->title);
}
// Add the content renderable array to the main element.
$element['content'] = $block->content;
unset($block->content);
$element['#block'] = $block;
}
return $element;
}