ExtensionCriteria example

private ?string $orderBy = null;

    private string $orderSequence = self::ORDER_SEQUENCE_ASC;

    /** * @var FilterStruct[] */
    private array $filter = [];

    public static function fromArray(array $parameter): ExtensionCriteria
    {
        $criteria = new ExtensionCriteria();

        if (isset($parameter['limit'])) {
            $criteria->setLimit((int) $parameter['limit']);
        }

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

        if (isset($parameter['term'])) {
            $criteria->setSearch($parameter['term']);
        }
$extensionCriteria = ExtensionCriteria::fromArray([
            'limit' => 10,
            'page' => 5,
        ]);

        static::assertEquals(10, $extensionCriteria->getLimit());
        static::assertEquals(40, $extensionCriteria->getOffset());
    }

    public function testItIgnoresInvalidValuesForSortDirection(): void
    {
        $extensionCriteria = new ExtensionCriteria();

        $extensionCriteria->setOrderSequence('random');

        static::assertEquals(ExtensionCriteria::ORDER_SEQUENCE_ASC, $extensionCriteria->getOrderSequence());
    }

    public function testOrderSequenceDesc(): void
    {
        $extensionCriteria = new ExtensionCriteria();

        $extensionCriteria->setOrderSequence('DesC');

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