diff --git a/CHANGELOG.md b/CHANGELOG.md index bffac0c..2450e10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ * refactor: consolidate util classes * feat: default indexBy * feat: repositories now automatically detect indexBy +* refactor: `CriteriaPageable`, `CriteriaRecollection`, `MinimalCriteriaRecollection` + now respect default order by ## 0.8.0 diff --git a/packages/collections-domain/src/CriteriaPageable.php b/packages/collections-domain/src/CriteriaPageable.php index 754698b..3f80df7 100644 --- a/packages/collections-domain/src/CriteriaPageable.php +++ b/packages/collections-domain/src/CriteriaPageable.php @@ -14,7 +14,6 @@ namespace Rekalogika\Domain\Collections; use Doctrine\Common\Collections\Criteria; -use Doctrine\Common\Collections\Order; use Doctrine\Common\Collections\ReadableCollection; use Doctrine\Common\Collections\Selectable; use Rekalogika\Contracts\Collections\Exception\UnexpectedValueException; @@ -81,7 +80,7 @@ final private function __construct( $criteria = clone ($criteria ?? Criteria::create()); if (\count($criteria->orderings()) === 0) { - $criteria->orderBy(['id' => Order::Descending]); + $criteria->orderBy(Configuration::$defaultOrderBy); } $this->criteria = $criteria; diff --git a/packages/collections-domain/src/CriteriaRecollection.php b/packages/collections-domain/src/CriteriaRecollection.php index f292245..1fee32e 100644 --- a/packages/collections-domain/src/CriteriaRecollection.php +++ b/packages/collections-domain/src/CriteriaRecollection.php @@ -99,7 +99,7 @@ final private function __construct( $criteria = clone ($criteria ?? Criteria::create()); if (\count($criteria->orderings()) === 0) { - $criteria->orderBy(['id' => Order::Descending]); + $criteria->orderBy(Configuration::$defaultOrderBy); } $this->criteria = $criteria; diff --git a/packages/collections-domain/src/MinimalCriteriaRecollection.php b/packages/collections-domain/src/MinimalCriteriaRecollection.php index 5f5e1af..8789081 100644 --- a/packages/collections-domain/src/MinimalCriteriaRecollection.php +++ b/packages/collections-domain/src/MinimalCriteriaRecollection.php @@ -14,7 +14,6 @@ namespace Rekalogika\Domain\Collections; use Doctrine\Common\Collections\Criteria; -use Doctrine\Common\Collections\Order; use Doctrine\Common\Collections\ReadableCollection; use Doctrine\Common\Collections\Selectable; use Rekalogika\Contracts\Collections\Exception\UnexpectedValueException; @@ -82,7 +81,7 @@ final private function __construct( $criteria = clone ($criteria ?? Criteria::create()); if (\count($criteria->orderings()) === 0) { - $criteria->orderBy(['id' => Order::Descending]); + $criteria->orderBy(Configuration::$defaultOrderBy); } $this->criteria = $criteria;