Commit 549fa06b authored by xiaohua guan's avatar xiaohua guan Committed by Yas Naoi
Browse files

Issue #3181189 by Xiaohua Guan, yas: Fix a cloud service provider menu access

parent 9016ddf2
Loading
Loading
Loading
Loading
+32
Changes for cloud.module: 32 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -357,3 +357,35 @@ function cloud_update_views_configuration($view_name, array $options) {
  }
  $view->save(TRUE);
}

/**
 * Implements hook_preprocess_HOOK().
 */
function cloud_preprocess_menu(&$variables) {
  // Remove cloud service provider menus without sub-menu.
  if (!empty($variables['menu_name']) && $variables['menu_name'] === 'main') {
    $variables['#cache']['max-age'] = 0;

    if (empty($variables['items'])) {
      return;
    }

    foreach (['cloud.service_providers.menu', 'cloud.design.menu'] as $menu) {
      if (empty($variables['items'][$menu])) {
        continue;
      }

      foreach (($parent =& $variables['items'][$menu]['below']) as $key => $item) {
        // Skip the menu "add cloud service provider".
        if ($key === 'cloud.menu.cloud_links:cloud_service_provider.local_tasks') {
          continue;
        }

        // If there is no sub-menu, remove the parent menu.
        if (empty($item['below'])) {
          unset($parent[$key]);
        }
      }
    }
  }
}