function Sql::assignEntitiesToResult
Same name in other branches
- 9 core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::assignEntitiesToResult()
- 8.9.x core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::assignEntitiesToResult()
- 11.x core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::assignEntitiesToResult()
Sets entities onto the view result row objects.
This method takes into account the relationship in which the entity was needed in the first place.
Parameters
mixed[][] $ids: A two dimensional array of identifiers (entity ID / revision ID) keyed by relationship.
\Drupal\Core\Entity\EntityInterface[] $entities: An array of entities keyed by their identified (entity ID / revision ID).
\Drupal\views\ResultRow[] $results: The entire views result.
Return value
\Drupal\views\ResultRow[] The changed views results.
1 call to Sql::assignEntitiesToResult()
- Sql::loadEntities in core/
modules/ views/ src/ Plugin/ views/ query/ Sql.php - Loads all entities contained in the passed-in $results.
File
-
core/
modules/ views/ src/ Plugin/ views/ query/ Sql.php, line 1671
Class
- Sql
- Views query plugin for an SQL query.
Namespace
Drupal\views\Plugin\views\queryCode
protected function assignEntitiesToResult($ids, array $entities, array $results) {
foreach ($ids as $index => $relationships) {
foreach ($relationships as $relationship_id => $id) {
if (isset($entities[$id])) {
$entity = $entities[$id];
}
else {
$entity = NULL;
}
if ($relationship_id == 'none') {
$results[$index]->_entity = $entity;
}
else {
$results[$index]->_relationship_entities[$relationship_id] = $entity;
}
}
}
return $results;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.