You are here

protected function Display::sortBlocks in Layout 8.2

Transform the stored blockConfig into a sorted, region-oriented array.

2 calls to Display::sortBlocks()
Display::getAllSortedBlocks in lib/Drupal/layout/Entity/Display.php
Implements BoundDisplayInterface::getAllSortedBlocks().
Display::getSortedBlocksByRegion in lib/Drupal/layout/Entity/Display.php
Implements BoundDisplayInterface::getSortedBlocksByRegion().

File

lib/Drupal/layout/Entity/Display.php, line 104
Definition of Drupal\layout\Entity\Display.

Class

Display
Defines the display entity.

Namespace

Drupal\layout\Entity

Code

protected function sortBlocks() {
  $layout_instance = $this
    ->getLayoutInstance();
  if ($this->layout !== $layout_instance
    ->getPluginId()) {
    $block_config = $this
      ->mapBlocksToLayout($layout_instance);
  }
  else {
    $block_config = $this->blockInfo;
  }
  $this->blocksInRegions = array();
  $regions = array_fill_keys(array_keys($layout_instance
    ->getRegions()), array());
  foreach ($block_config as $config_name => $info) {
    $regions[$info['region']][$config_name] = $info;
  }
  foreach ($regions as $region_name => &$blocks) {
    uasort($blocks, 'drupal_sort_weight');
    $this->blocksInRegions[$region_name] = array_keys($blocks);
  }
}