function SqlContentEntityStorage::getFromStorage

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::getFromStorage()
  2. 8.9.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::getFromStorage()
  3. 11.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::getFromStorage()

Gets entities from the storage.

Parameters

array|null $ids: If not empty, return entities that match these IDs. Return all entities when NULL.

Return value

\Drupal\Core\Entity\ContentEntityInterface[] Array of entities from the storage.

1 call to SqlContentEntityStorage::getFromStorage()
SqlContentEntityStorage::doLoadMultiple in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php, line 412

Class

SqlContentEntityStorage
A content entity database storage implementation.

Namespace

Drupal\Core\Entity\Sql

Code

protected function getFromStorage(?array $ids = NULL) {
    $entities = [];
    if (!empty($ids)) {
        // Sanitize IDs. Before feeding ID array into buildQuery, check whether
        // it is empty as this would load all entities.
        $ids = $this->cleanIds($ids);
    }
    if ($ids === NULL || $ids) {
        // Build and execute the query.
        $query_result = $this->buildQuery($ids)
            ->execute();
        $records = $query_result->fetchAllAssoc($this->idKey);
        // Map the loaded records into entity objects and according fields.
        if ($records) {
            $entities = $this->mapFromStorageRecords($records);
        }
    }
    return $entities;
}

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