mirror of
https://github.com/YGGverse/HLState.git
synced 2025-02-11 06:24:33 +00:00
sort servers by players quantity by default
This commit is contained in:
parent
f61487cc9f
commit
80e362a131
@ -33,12 +33,7 @@ class MainController extends AbstractController
|
|||||||
// Collect servers info
|
// Collect servers info
|
||||||
$servers = [];
|
$servers = [];
|
||||||
|
|
||||||
foreach ((array) $entityManagerInterface->getRepository(Server::class)->findBy(
|
foreach ((array) $entityManagerInterface->getRepository(Server::class)->findAll() as $server)
|
||||||
[],
|
|
||||||
[
|
|
||||||
'online' => 'desc'
|
|
||||||
]
|
|
||||||
) as $server)
|
|
||||||
{
|
{
|
||||||
// Init defaults
|
// Init defaults
|
||||||
$status = false;
|
$status = false;
|
||||||
@ -106,10 +101,21 @@ class MainController extends AbstractController
|
|||||||
'updated' => $server->getUpdated(),
|
'updated' => $server->getUpdated(),
|
||||||
'online' => $server->getOnline(),
|
'online' => $server->getOnline(),
|
||||||
'info' => $info,
|
'info' => $info,
|
||||||
'status' => $status
|
'status' => $status,
|
||||||
|
'sort' => empty($info['Players']) ? 0 : (int) $info['Players']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort by players
|
||||||
|
array_multisort(
|
||||||
|
array_column(
|
||||||
|
$servers,
|
||||||
|
'sort'
|
||||||
|
),
|
||||||
|
SORT_DESC,
|
||||||
|
$servers
|
||||||
|
);
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
'default/main/index.html.twig',
|
'default/main/index.html.twig',
|
||||||
[
|
[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user