Transform the stored blockConfig into a sorted, region-oriented array.
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);
}
}