You are here

function esi_block__esi_block_render in ESI: Edge Side Includes 7.3

Render the HTML for a single block. Defined in hook_esi_component_info().

See also

esi_block_esi_component_info()

2 string references to 'esi_block__esi_block_render'
esi_block_esi_component_info in modules/esi_block/esi_block.module
Implements hook_esi_component().
hook_esi_component in ./esi.api.inc
Declare a handler for delivering content through ESI.

File

modules/esi_block/esi_block.esi.inc, line 71
ESI handlers for ESI Block.

Code

function esi_block__esi_block_render($block) {
  $build = array();

  // Reproduce functionality of _block_render_blocks().
  $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 (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);
    }
    if (!isset($block->subject)) {
      $block->subject = '';
    }

    // Reproduce functionality of _block_get_renderable_array().
    $key = "{$block->module}_{$block->delta}";
    $build[$key] = $block->content;
    unset($block->content);
    if ($key != 'system_main' && $key != 'system_help') {
      $build[$key]['#contextual_links']['block'] = array(
        'admin/structure/block/manage',
        array(
          $block->module,
          $block->delta,
        ),
      );
    }
    $build[$key] += array(
      '#block' => $block,
    );
    $build[$key]['#theme_wrappers'][] = 'block';
  }
  esi_block_set_http_headers($block);
  return $build;
}