- 🇺🇸United States smustgrave
MR 1308 had a CI failure.
Did not test or review.
The
#2942426: [DISCUSSION] Remove query counting and collection counts? →
explains that without a JSON:API Extras it's *almost* impossible to get a total number of items for a collection request within meta.count
. This caused by the "static" code of Drupal\jsonapi\ResourceType\ResourceType::includeCount()
:
public function includeCount() {
// By default, do not return counts in collection queries.
return FALSE;
}
string|null $totalCountMetaName
to the Drupal\jsonapi\ResourceType\ResourceType
.string|null $total_count_meta_name = NULL
as the argument to Drupal\jsonapi\ResourceType\ResourceType::__construct()
and assign it to $this->totalCountMetaName
.Drupal\jsonapi\ResourceType\ResourceType::includeCount()
and return $this->totalCountMetaName !== NULL
, so the total count is included for collection responses if the meta name is provided.Drupal\jsonapi\ResourceType\ResourceType::getTotalCountMetaName(): ?string
that returns $this->totalCountMetaName
or 'count'
if the Drupal\jsonapi\ResourceType\ResourceType::includeCount()
method is overridden.Drupal\jsonapi\Controller\EntityResource::respondWithCollection()
use $meta[$resource_type->getTotalCountMetaName()]
instead of $meta['count']
.Drupal\jsonapi\ResourceType\ResourceTypeBuildEvent
, introduce string|null $totalCountMetaName
, setTotalCountMetaName(?string $name): void
, and getTotalCountMetaName(): ?string
that will allow changing the resource definition at a build time.Drupal\jsonapi\ResourceType\ResourceTypeRepository::createResourceType()
, query $event->getTotalCountMetaName()
for non-internal resource types and pass the value to new ResourceType
.Needs work
10.1 ✨
Last updated
Used to track the progress of issues reviewed by the Drupal Needs Review Queue Initiative.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
MR 1308 had a CI failure.
Did not test or review.