public function MenuTreeStorage::getExpanded

public MenuTreeStorage::getExpanded($menu_name, array $parents)

Finds expanded links in a menu given a set of possible parents.

Parameters

string $menu_name: The menu name.

array $parents: One or more parent IDs to match.

Return value

array The menu link IDs that are flagged as expanded in this menu.

Overrides MenuTreeStorageInterface::getExpanded

File

core/lib/Drupal/Core/Menu/MenuTreeStorage.php, line 783

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

public function getExpanded($menu_name, array $parents) {
  // @todo Go back to tracking in state or some other way which menus have
  //   expanded links? https://www.drupal.org/node/2302187
  do {
    $query = $this->connection->select($this->table, $this->options);
    $query->fields($this->table, array('id'));
    $query->condition('menu_name', $menu_name);
    $query->condition('expanded', 1);
    $query->condition('has_children', 1);
    $query->condition('enabled', 1);
    $query->condition('parent', $parents, 'IN');
    $query->condition('id', $parents, 'NOT IN');
    $result = $this->safeExecuteSelect($query)->fetchAllKeyed(0, 0);
    $parents += $result;
  } while (!empty($result));
  return $parents;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!MenuTreeStorage.php/function/MenuTreeStorage::getExpanded/8.1.x