You are here

public function UltimenuManager::buildDataRegion in Ultimenu 8

Returns the renderable array region data.

Return value

array The region data.

Overrides UltimenuManagerInterface::buildDataRegion

1 call to UltimenuManager::buildDataRegion()
UltimenuManager::buildMenuTree in src/UltimenuManager.php
Build the menu to contain Ultimenu regions.

File

src/UltimenuManager.php, line 502

Class

UltimenuManager
Manages Ultimenu plugin.

Namespace

Drupal\ultimenu

Code

public function buildDataRegion(&$region, $children = []) {
  $build = [];
  $blocks = [];
  $config = $region['config'];
  $reverse = FALSE;
  $content = [];
  if ($children) {
    $reverse = !empty($config['submenu_position']) && $config['submenu_position'] == 'bottom';
    $content[] = $children;
  }
  if ($blocks = $this
    ->getBlocksByRegion($region['region'])) {
    $content[] = $blocks;
  }
  if ($content = array_filter($content)) {
    $build['content'] = $reverse ? array_reverse($content, TRUE) : $content;
    $build['#config'] = $config;
    $build['#region'] = $region['region'];
    $build['#sorted'] = TRUE;

    // Add the region theme wrapper for the Ultimenu flyout.
    $build['#theme_wrappers'][] = 'region';
  }
  return $build;
}