function EntityStorageBase::buildPropertyQuery

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::buildPropertyQuery()
  2. 8.9.x core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::buildPropertyQuery()
  3. 11.x core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::buildPropertyQuery()

Builds an entity query.

Parameters

\Drupal\Core\Entity\Query\QueryInterface $entity_query: EntityQuery instance.

array $values: An associative array where the keys are the property names and the values are the values those properties must have. If a property takes multiple values, passing an array of values will produce an IN condition.

2 calls to EntityStorageBase::buildPropertyQuery()
EntityStorageBase::loadByProperties in core/lib/Drupal/Core/Entity/EntityStorageBase.php
Load entities by their property values without any access checks.
SqlContentEntityStorage::buildPropertyQuery in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
Builds an entity query.
1 method overrides EntityStorageBase::buildPropertyQuery()
SqlContentEntityStorage::buildPropertyQuery in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
Builds an entity query.

File

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

Class

EntityStorageBase
A base entity storage class.

Namespace

Drupal\Core\Entity

Code

protected function buildPropertyQuery(QueryInterface $entity_query, array $values) {
    foreach ($values as $name => $value) {
        // Cast scalars to array so we can consistently use an IN condition.
        $entity_query->condition($name, (array) $value, 'IN');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.