Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Sql.php

function 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 1693

Class

Sql
Views query plugin for an SQL query.

Namespace

Drupal\views\Plugin\views\query

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal