Re-order array by key [ci skip]

References #3
This commit is contained in:
Oliver Davies 2021-01-11 01:59:31 +00:00
parent f404019a39
commit cca8ed1970

View file

@ -68,12 +68,12 @@ class RelatedPostsBlock extends BlockBase implements ContainerFactoryPluginInter
'max-age' => 604800,
'tags' => ["node:{$currentPost->id()}"],
],
'#theme' => 'item_list',
'#items' => $relatedPosts
->sortByDesc(fn(Post $post) => $post->getCreatedTime())
->map(fn(Post $post) => $this->generateLinkToPost($post))
->slice(0, 3)
->toArray(),
'#theme' => 'item_list',
];
return $build;