Skip to content

Set default $currentOrder in Sort class #212

@Tigrov

Description

@Tigrov

$currentOrder can be set to default value after normalizing config.

data/src/Reader/Sort.php

Lines 114 to 126 in 15ddd6e

$normalizedConfig[$fieldName] = array_merge(
[
'asc' => [$fieldName => SORT_ASC],
'desc' => [$fieldName => SORT_DESC],
'default' => 'asc',
],
$fieldConfig,
);
}
/** @psalm-var TConfig $normalizedConfig */
$this->config = $normalizedConfig;
}

This will help avoid an exception if $currentOrder is not set manually.

if (empty($sort->getOrder())) {
throw new InvalidArgumentException('Data should be always sorted to work with keyset pagination.');
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions