src/Controller/EntityResource.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Controller/EntityResource.php b/src/Controller/EntityResource.php index 00abd24..575ab76 100644 --- a/src/Controller/EntityResource.php +++ b/src/Controller/EntityResource.php @@ -385,7 +385,7 @@ class EntityResource { $entity_collection->setTotalCount($total_results); } - $response = $this->respondWithCollection($entity_collection, $entity_type_id); + $response = $this->respondWithCollection($entity_collection, $resource_type); $response->addCacheableDependency($query_cacheability); @@ -808,16 +808,16 @@ class EntityResource { * * @param \Drupal\jsonapi\JsonApiResource\EntityCollection $entity_collection * The collection of entites. - * @param string $entity_type_id - * The entity type. + * @param \Drupal\jsonapi\ResourceType\ResourceType $resource_type + * The base JSON API resource type for the request to be served. * * @return \Drupal\jsonapi\ResourceResponse * The response. */ - protected function respondWithCollection(EntityCollection $entity_collection, $entity_type_id) { + protected function respondWithCollection(EntityCollection $entity_collection, ResourceType $resource_type) { $link_context = [ 'has_next_page' => $entity_collection->hasNextPage(), - 'total_count' => $this->resourceType->includeCount() + 'total_count' => $resource_type->includeCount() ? $entity_collection->getTotalCount() : FALSE ]; @@ -826,7 +826,7 @@ class EntityResource { // When a new change to any entity in the resource happens, we cannot ensure // the validity of this cached list. Add the list tag to deal with that. - $list_tag = $this->entityTypeManager->getDefinition($entity_type_id) + $list_tag = $this->entityTypeManager->getDefinition($resource_type->getEntityTypeId()) ->getListCacheTags(); $response->getCacheableMetadata()->addCacheTags($list_tag); foreach ($entity_collection as $entity) {