public function MongodbMenuTreeStorage::loadByProperties in MongoDB 8
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 MenuTreeStorage::loadByProperties
File
- src/
MongodbMenuTreeStorage.php, line 365 - Contains \Drupal\mongodb\MongodbMenuTreeStorage .
Class
Namespace
Drupal\mongodbCode
public function loadByProperties(array $properties) {
$query = [];
foreach ($properties as $name => $value) {
if (!in_array($name, $this
->definitionFields(), TRUE)) {
$fields = implode(', ', $this
->definitionFields());
throw new \InvalidArgumentException(String::format('An invalid property name, @name was specified. Allowed property names are: @fields.', array(
'@name' => $name,
'@fields' => $fields,
)));
}
$query["value.{$name}"] = $value;
}
$loaded = [];
foreach ($this
->mongoCollection()
->find($query) as $link) {
$loaded[$link['value']['id']] = $this
->prepareLink($link['value']);
}
return $loaded;
}