MenuTreeStorage::loadByProperties

public MenuTreeStorage::loadByProperties(array $properties)

Loads multiple plugin definitions from the storage based on properties.

Parameters

array $properties: The properties to filter by.

Return value

array An array of menu link definition arrays.

Throws

\InvalidArgumentException Thrown if an invalid property name is specified in $properties.

Overrides MenuTreeStorageInterface::loadByProperties

File

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

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, $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;
}
doc_Drupal
2016-10-29 09:27:38
Comments
Leave a Comment

Please login to continue.