Oihana PHP Arango

PrepareFacetCountsLimitTrait

Prepares the per-request number of buckets each counted dimension keeps (see {@see \oihana\arango\models\traits\queries\FacetCountsQueryTrait}).

Driven by ?facetCountsLimit=, which takes a positive integer or the FacetParam::ALL keyword. It overrides the Facet::LIMIT declared on the facet — a default, not a ceiling — so a request may raise it, lower it, or cancel it outright:

?facetCounts=keywords                        // the declaration decides
?facetCounts=keywords&facetCountsLimit=25    // the 25 biggest buckets
?facetCounts=keywords&facetCountsLimit=all   // every bucket

There is no ceiling to enforce, and that is a property of how the counts are built rather than an oversight: the COLLECT computes every bucket whatever the limit, which only trims what travels. A request asking for more buckets than exist receives the ones that exist — the behaviour it would get with no limit at all.

The keyword never reaches the model. It is translated here into false, the model-level way to say "explicitly unlimited", which the model tells apart from an absent parameter ("use the declaration"). The same separation PrepareGroupTrait::prepareGroup() keeps between the HTTP vocabulary and the model's own.

Tags
since
1.7.0
author

Marc Alcaraz

Table of Contents

Methods

prepareFacetCountsLimit()  : int|false|null
Resolves the per-request bucket limit for a list query.

Methods

prepareFacetCountsLimit()

Resolves the per-request bucket limit for a list query.

protected prepareFacetCountsLimit(ServerRequestInterface|null $request[, array<string|int, mixed> $args = [] ][, array<string|int, mixed>|null &$params = null ]) : int|false|null
Parameters
$request : ServerRequestInterface|null

The HTTP request.

$args : array<string|int, mixed> = []

Predefined options ($args[Arango::FACET_COUNTS_LIMIT] as base).

$params : array<string|int, mixed>|null = null

Echoed query params, populated by reference.

Tags
throws
RequestValidationException

When the request sent something that is neither a positive integer nor all.

Return values
int|false|null —

The number of buckets to keep, false for every bucket, or null when the declaration decides.

On this page

Search results