function MenuTreeStorage::loadByProperties

Same name in other branches
  1. 9 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::loadByProperties()
  2. 8.9.x core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::loadByProperties()
  3. 11.x core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::loadByProperties()
2 calls to MenuTreeStorage::loadByProperties()
MenuTreeStorage::delete in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
MenuTreeStorage::purgeMultiple in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
Purges multiple menu links that no longer exist.

File

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

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

public function loadByProperties(array $properties) {
    $query = $this->connection
        ->select($this->table, NULL, $this->options);
    $query->fields($this->table, $this->definitionFields());
    foreach ($properties as $name => $value) {
        if (!in_array($name, $this->definitionFields(), TRUE)) {
            $fields = implode(', ', $this->definitionFields());
            throw new \InvalidArgumentException("An invalid property name, {$name} was specified. Allowed property names are: {$fields}.");
        }
        $query->condition($name, $value);
    }
    $loaded = $this->safeExecuteSelect($query)
        ->fetchAllAssoc('id', \PDO::FETCH_ASSOC);
    foreach ($loaded as $id => $link) {
        $loaded[$id] = $this->prepareLink($link);
    }
    return $loaded;
}

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