1 layout.admin.inc layout_get_block_usage($module = NULL, $delta = NULL)

Lists information about blocks in use in layouts.

Parameters

string $module: The module providing the required blocks.

string $delta: The block delta. If $delta is provided, $module is also required since block deltas are not required to be unique.

Return value

array: An array of block usage instances keyed by block module, delta, layout machine_name, and position. Each instance is a block object with an additional key for the layout name.

File

core/modules/layout/layout.admin.inc, line 3631
Admin page callbacks for the Layout module.

Code

function layout_get_block_usage($module = NULL, $delta = NULL) {
  $blocks = &backdrop_static(__FUNCTION__, array());
  if (empty($blocks)) {
    $layout_info = layout_load_all();
    foreach ($layout_info as $layout) {
      foreach ($layout->positions as $position => $uuids) {
        foreach ($uuids as $uuid) {
          $block = $layout->content[$uuid];
          $block->layout_title = $layout->title;
          $blocks[$block->module][$block->delta][$layout->name][$position][] = $block;
        }
      }
    }
  }

  if ($module && $delta) {
    return $blocks[$module][$delta];
  }
  elseif ($module) {
    return $blocks[$module];
  }
  return $blocks;
}