1.20.x layout.module layout_get_block_info($block_module = NULL, $block_delta = NULL)

Get information about all blocks or just a single one.

Parameters

$block_module: The name of a module providing the desired block.

$block_delta: The key of the block within that module.

Return value

array: The information from hook_block_info() for the requests block(s).

File

modules/layout/layout.module, line 1627
The Layout module creates pages and wraps existing pages in layouts.

Code

function layout_get_block_info($block_module = NULL, $block_delta = NULL) {
  $block_info = &backdrop_static(__FUNCTION__, array(
    'all' => NULL, // Set TRUE when block info for all modules has been loaded.
    'modules' => array(), // The actual list of stored block info, per module.
  ));

  if (isset($block_module)) {
    $modules = array($block_module);
  }
  elseif (!isset($block_info['all'])) {
    $modules = module_implements('block_info');
    $block_info['all'] = TRUE;
  }
  else {
    $modules = array();
  }

  // Load each module's block info that is required.
  $new_block_info = array();
  foreach ($modules as $module) {
    if (!isset($block_info['modules'][$module])) {
      $new_block_info[$module] = module_invoke($module, 'block_info');
    }
  }

  // Alter and merge the collection of new blocks.
  if (!empty($new_block_info)) {
    backdrop_alter('block_info', $new_block_info);
    $block_info['modules'] = array_merge($block_info['modules'], $new_block_info);
  }

  // Return partial or full results based on the requested properties.
  if (isset($block_module) && isset($block_delta)) {
    if (isset($block_info['modules'][$block_module][$block_delta])) {
      return $block_info['modules'][$block_module][$block_delta];
    }
    else {
      return FALSE;
    }
  }
  elseif (isset($block_module)) {
    if (isset($block_info['modules'][$block_module])) {
      return $block_info['modules'][$block_module];
    }
    else {
      return FALSE;
    }
  }

  return $block_info['modules'];
}