Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::loadByProperties()
  2. 9 core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::loadByProperties()

Load entities by their property values.

Parameters

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

Return value

\Drupal\Core\Entity\EntityInterface[] An array of entity objects indexed by their ids.

Overrides EntityStorageInterface::loadByProperties

3 methods override EntityStorageBase::loadByProperties()
ContentEntityNullStorage::loadByProperties in core/lib/Drupal/Core/Entity/ContentEntityNullStorage.php
Load entities by their property values.
FieldConfigStorage::loadByProperties in core/modules/field/src/FieldConfigStorage.php
Load entities by their property values.
FieldStorageConfigStorage::loadByProperties in core/modules/field/src/FieldStorageConfigStorage.php
Load entities by their property values.

File

core/lib/Drupal/Core/Entity/EntityStorageBase.php, line 572

Class

EntityStorageBase
A base entity storage class.

Namespace

Drupal\Core\Entity

Code

public function loadByProperties(array $values = []) {

  // Build a query to fetch the entity IDs.
  $entity_query = $this
    ->getQuery();
  $entity_query
    ->accessCheck(FALSE);
  $this
    ->buildPropertyQuery($entity_query, $values);
  $result = $entity_query
    ->execute();
  return $result ? $this
    ->loadMultiple($result) : [];
}