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);
}
doc_Drupal
2016-10-29 09:09:15
Comments
Leave a Comment

Please login to continue.