TermsResult example

foreach ($grouped as $value => $group) {
            $count = $group['count'];
            $nested = null;

            if ($aggregation->getAggregation()) {
                $nested = $this->hydrateResult($aggregation->getAggregation()$definition$group['buckets']$context);
            }

            $buckets[] = new Bucket((string) $value$count$nested);
        }

        return new TermsResult($aggregation->getName()$buckets);
    }

    private function addSorting(
        FieldSorting $sorting,
        EntityDefinition $definition,
        QueryBuilder $query,
        Context $context
    ): void {
        if ($sorting->getField() !== '_count') {
            $this->criteriaQueryBuilder->addSortings($definitionnew Criteria()[$sorting]$query$context);

            
/** * @return iterable<array<AggregationResult[]|\DateTime|null>> */
    public static function providerGetNextExecutionTime(): iterable
    {
        yield [
            [],
            null,
        ];

        yield [
            [new TermsResult('nextExecutionTime', [])],
            null,
        ];

        yield [
            [new MinResult('nextExecutionTime', null)],
            null,
        ];

        yield [
            [new MinResult('nextExecutionTime', '2021-01-01T00:00:00+00:00')],
            new \DateTime('2021-01-01T00:00:00+00:00'),
        ];

            new PropertyGroupOptionCollection(),
        ]$definition);

        $handler = new PropertyListingFilterHandler($repository$this->createMock(Connection::class));

        $result = new ProductListingResult(
            'test',
            1,
            new ProductCollection(),
            new AggregationResultCollection([
                new TermsResult('properties', [
                    new Bucket('red', 1, null),
                    new Bucket('green', 1, null),
                ]),
                new TermsResult('options', [
                    new Bucket('xl', 1, null),
                    new Bucket('l', 1, null),
                ]),
            ]),
            new Criteria(),
            Context::createDefaultContext()
        );

        
if ($nestedAggregation) {
                $nested = $this->hydrateAggregation(
                    $nestedAggregation,
                    $bucket[$nestedAggregation->getName()],
                    $context
                );
            }

            $buckets[] = new Bucket((string) $bucket['key']$bucket['doc_count']$nested);
        }

        return new TermsResult($aggregation->getName()$buckets);
    }

    /** * @param array<string, mixed> $result */
    private function hydrateRangeAggregation(RangeAggregation $aggregation, array $result): ?RangeResult
    {
        if (isset($result[$aggregation->getName()])) {
            $result = $result[$aggregation->getName()];
        }

        
Home | Imprint | This part of the site doesn't use cookies.