4k: Sort articles before returning
This commit is contained in:
parent
91f7d094e7
commit
290c8fbcba
|
@ -14,10 +14,20 @@ class ArticleRepository {
|
|||
}
|
||||
|
||||
public function getAll(): array {
|
||||
return $this->nodeStorage->loadByProperties([
|
||||
$articles = $this->nodeStorage->loadByProperties([
|
||||
'status' => NodeInterface::PUBLISHED,
|
||||
'type' => 'article',
|
||||
]);
|
||||
|
||||
$this->sortByCreatedDate($articles);
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
private function sortByCreatedDate(array &$articles): void {
|
||||
uasort($articles, function (NodeInterface $a, NodeInterface $b): bool {
|
||||
return $a->getCreatedTime() < $b->getCreatedTime();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue