setOrderBy example

if (isset($parameter['page'])) {
            $criteria->setOffset(((int) $parameter['page'] - 1) * $criteria->getLimit());
        }

        if (isset($parameter['term'])) {
            $criteria->setSearch($parameter['term']);
        }

        $sorting = $parameter['sort'][0] ?? null;
        if ($sorting !== null) {
            $criteria->setOrderBy($sorting['field']);
            $criteria->setOrderSequence($sorting['order']);
        }

        if (isset($parameter['filter'])) {
            foreach ($parameter['filter'] as $filter) {
                $criteria->addFilter($filter);
            }
        }

        return $criteria;
    }

    
'rating' => 3,
            'category' => 'living',
        ]$criteria->getQueryParameter());
    }

    public function testToQueryStringSkipsOrderSequenceIfNoOrderByIsGiven(): void
    {
        $extensionCriteria = new ExtensionCriteria();
        static::assertArrayNotHasKey('orderSequence', $extensionCriteria->getQueryParameter());
        static::assertArrayNotHasKey('orderBy', $extensionCriteria->getQueryParameter());

        $extensionCriteria->setOrderBy('rating');

        static::assertEquals('rating', $extensionCriteria->getQueryParameter()['orderBy']);
        static::assertEquals('rating', $extensionCriteria->getOrderBy());
        static::assertEquals(
            ExtensionCriteria::ORDER_SEQUENCE_ASC,
            $extensionCriteria->getQueryParameter()['orderSequence']
        );
    }

    public function testToQueryStringSkipsSearchIfNotPresent(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.