You are here

protected function EntityQueryResourceBase::loadResourceObjectDataFromEntityQuery in JSON:API Resources 8

Finds entity resource object using an entity query.

Parameters

\Drupal\Core\Entity\Query\QueryInterface $entity_query: The entity query object.

\Drupal\Core\Cache\CacheableMetadata $cacheable_metadata: A CacheableMetadata object that will be used to capture any cacheability information generated while generating pagination links. The same object that is passed to this method should be added to the cacheability of the final response by the caller.

bool $load_latest_revisions: (optional) Whether to load the latest revisions instead of the defaults. Defaults to FALSE.

bool $check_access: (optional) Whether to check access on the loaded entities or not. Defaults to TRUE.

Return value

\Drupal\jsonapi\JsonApiResource\ResourceObjectData The resource object data that was found and access checked.

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException Thrown if the entity type doesn't exist.

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException Thrown if the storage handler couldn't be loaded.

2 calls to EntityQueryResourceBase::loadResourceObjectDataFromEntityQuery()
AuthorArticles::process in tests/modules/jsonapi_resources_test/src/Resource/AuthorArticles.php
Process the resource request.
FeaturedNodes::process in tests/modules/jsonapi_resources_test/src/Resource/FeaturedNodes.php
Process the resource request.

File

src/Resource/EntityQueryResourceBase.php, line 94

Class

EntityQueryResourceBase
Defines basic functionality for an entity query-oriented JSON:API Resource.

Namespace

Drupal\jsonapi_resources\Resource

Code

protected function loadResourceObjectDataFromEntityQuery(QueryInterface $entity_query, CacheableMetadata $cacheable_metadata, $load_latest_revisions = FALSE, $check_access = TRUE) : ResourceObjectData {
  $entity_type_id = $entity_query
    ->getEntityTypeId();
  $results = $this->entityQueryExecutor
    ->executeQueryAndCaptureCacheability($entity_query, $cacheable_metadata);
  return $this
    ->loadResourceObjectsByEntityIds($entity_type_id, $results, $load_latest_revisions, $check_access);
}