From da68637ba01691fee31dd81e96ee7e7f67e3dfd1 Mon Sep 17 00:00:00 2001 From: Mike Colagrosso Date: Tue, 11 Jun 2024 15:46:23 -0600 Subject: [PATCH] Get list of collections from DB --- lib/Library.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/Library.php b/lib/Library.php index cd947486..2902b24f 100644 --- a/lib/Library.php +++ b/lib/Library.php @@ -140,12 +140,21 @@ class Library{ } /** - * @return array + * @return array * @throws Exceptions\AppException */ public static function GetEbookCollections(): array{ - /** @var array */ - return self::GetFromApcu('collections'); + $collections = Db::Query(' + SELECT distinct UrlName, Name + from Collections + ', [], Collection::class); + + $collator = Collator::create('en_US'); + if($collator === null){ + throw new Exceptions\AppException('Couldn\'t create collator object when getting collections.'); + } + usort($collections, function($a, $b) use($collator){ return $collator->compare($a->GetSortedName(), $b->GetSortedName()); }); + return $collections; } /**