You are here

public function UltimenuManager::getFlyout in Ultimenu 8.2

Returns the flyout if available.

1 call to UltimenuManager::getFlyout()
UltimenuManager::buildMenuItem in src/UltimenuManager.php
Build the Ultimenu item.

File

src/UltimenuManager.php, line 482

Class

UltimenuManager
Implements UltimenuManagerInterface.

Namespace

Drupal\ultimenu

Code

public function getFlyout($region, array &$config) {
  $flyout = [];
  if ($regions = $this
    ->getSetting('regions')) {
    if (!empty($regions[$region])) {

      // Simply display the flyout, if AJAX is disabled.
      if (empty($config['ajaxify'])) {
        $flyout = $this
          ->buildFlyout($region, $config);
      }
      else {

        // We have a mix of (non-)ajaxified regions here.
        // Provides an AJAX link as a fallback and also the trigger.
        // No need to check whether the region is empty, or not, as otherwise
        // defeating the purpose of ajaxified regions, to gain performance.
        // The site builder should at least provide one accessible block
        // regardless of complex visibility by paths or roles. A trade off.
        $ajax_regions = isset($config['regions']) ? array_filter($config['regions']) : [];
        $config['is_ajax_region'] = $ajax_regions && in_array($region, $ajax_regions);
        $flyout = $config['is_ajax_region'] ? $this
          ->buildAjaxLink($config) : $this
          ->buildFlyout($region, $config);
      }
    }
  }
  return $flyout;
}