function toolbar_get_rendered_subtrees

Returns the rendered subtree of each top-level toolbar link.

2 calls to toolbar_get_rendered_subtrees()
ToolbarController::subtreesJsonp in drupal/core/modules/toolbar/lib/Drupal/toolbar/Routing/ToolbarController.php
Returns the rendered subtree of each top-level toolbar link.
_toolbar_get_subtree_hash in drupal/core/modules/toolbar/toolbar.module
Returns the hash of the per-user rendered toolbar subtrees.

File

drupal/core/modules/toolbar/toolbar.module, line 525
Administration toolbar for quick access to top level administration items.

Code

function toolbar_get_rendered_subtrees() {
  $subtrees = array();
  $tree = toolbar_get_menu_tree();
  foreach ($tree as $tree_item) {
    $item = $tree_item['link'];
    if (!$item['hidden'] && $item['access']) {
      if ($item['has_children']) {
        $query = db_select('menu_links');
        $query
          ->addField('menu_links', 'mlid');
        $query
          ->condition('has_children', 1);
        for ($i = 1; $i <= $item['depth']; $i++) {
          $query
            ->condition('p' . $i, $item['p' . $i]);
        }
        $parents = $query
          ->execute()
          ->fetchCol();
        $subtree = menu_build_tree($item['menu_name'], array(
          'expanded' => $parents,
          'min_depth' => $item['depth'] + 1,
        ));
        toolbar_menu_navigation_links($subtree);
        $subtree = menu_tree_output($subtree);
        $subtree = drupal_render($subtree);
      }
      else {
        $subtree = '';
      }
      $id = str_replace(array(
        '/',
        '<',
        '>',
      ), array(
        '-',
        '',
        '',
      ), $item['href']);
      $subtrees[$id] = $subtree;
    }
  }
  return $subtrees;
}