function MenuTreeStorage::getExpanded

Same name in other branches
  1. 9 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::getExpanded()
  2. 8.9.x core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::getExpanded()
  3. 11.x core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::getExpanded()

File

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

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, NULL, $this->options);
        $query->fields($this->table, [
            '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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.