mirror of
https://github.com/standardebooks/web.git
synced 2025-07-15 19:06:49 -04:00
Get list of collections from DB
This commit is contained in:
parent
4653b15288
commit
da68637ba0
1 changed files with 12 additions and 3 deletions
|
@ -140,12 +140,21 @@ class Library{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, Collection>
|
* @return array<Collection>
|
||||||
* @throws Exceptions\AppException
|
* @throws Exceptions\AppException
|
||||||
*/
|
*/
|
||||||
public static function GetEbookCollections(): array{
|
public static function GetEbookCollections(): array{
|
||||||
/** @var array<string, Collection> */
|
$collections = Db::Query('
|
||||||
return self::GetFromApcu('collections');
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue