W3cubDocs

/Drupal 8

function entity_load_multiple_by_properties

entity_load_multiple_by_properties($entity_type, array $values)

Load entities by their property values.

\Drupal::entityTypeManager()
  ->getStorage($entity_type)
  ->loadByProperties($values);

Parameters

string $entity_type: The entity type to load, e.g. node or user.

array $values: An associative array where the keys are the property names and the values are the values those properties must have.

Return value

array An array of entity objects indexed by their IDs. Returns an empty array if no matching entities are found.

Deprecated

as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use the entity storage's loadByProperties() method to load an entity by their property values:

See also

\Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()

\Drupal\Core\Entity\EntityStorageInterface::loadByProperties()

File

core/includes/entity.inc, line 221
Entity API for handling entities like nodes or users.

Code

function entity_load_multiple_by_properties($entity_type, array $values) {
  return \Drupal::entityManager()
    ->getStorage($entity_type)
    ->loadByProperties($values);
}

© 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!includes!entity.inc/function/entity_load_multiple_by_properties/8.1.x