1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Database\View\RpgRanking; |
6
|
|
|
|
7
|
|
|
use Stu\Module\Control\GameControllerInterface; |
8
|
|
|
use Stu\Module\Control\ViewControllerInterface; |
9
|
|
|
use Stu\Module\Database\Lib\DatabaseTopListWithPoints; |
10
|
|
|
use Stu\Module\Database\Lib\DatabaseUiFactoryInterface; |
11
|
|
|
use Stu\Orm\Repository\KnPostRepositoryInterface; |
12
|
|
|
|
13
|
|
|
final class RpgRanking implements ViewControllerInterface |
14
|
|
|
{ |
15
|
|
|
public const VIEW_IDENTIFIER = 'SHOW_TOP_RPG'; |
16
|
|
|
|
17
|
|
|
private DatabaseUiFactoryInterface $databaseUiFactory; |
18
|
|
|
|
19
|
|
|
private KnPostRepositoryInterface $knPostRepository; |
20
|
|
|
|
21
|
|
|
public function __construct( |
22
|
|
|
DatabaseUiFactoryInterface $databaseUiFactory, |
23
|
|
|
KnPostRepositoryInterface $knPostRepository |
24
|
|
|
) { |
25
|
|
|
$this->databaseUiFactory = $databaseUiFactory; |
26
|
|
|
$this->knPostRepository = $knPostRepository; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function handle(GameControllerInterface $game): void |
30
|
|
|
{ |
31
|
|
|
$game->appendNavigationPart( |
32
|
|
|
'database.php', |
33
|
|
|
'Datenbank' |
34
|
|
|
); |
35
|
|
|
$game->appendNavigationPart( |
36
|
|
|
sprintf( |
37
|
|
|
'database.php?%s=1', |
38
|
|
|
static::VIEW_IDENTIFIER |
39
|
|
|
), |
40
|
|
|
'Die 10 bestbewerteten RPG-Schreiber' |
41
|
|
|
); |
42
|
|
|
$game->setPageTitle('/ Datenbank / Die 10 bestbewerteten RPG-Schreiber'); |
43
|
|
|
$game->showMacro('html/database.xhtml/top_rpg_user'); |
44
|
|
|
$game->setTemplateVar( |
45
|
|
|
'PRESTIGE_LIST', |
46
|
|
|
array_map( |
47
|
|
|
fn (array $data): DatabaseTopListWithPoints => $this->databaseUiFactory->createDatabaseTopListWithPoints($data['user_id'], (string) $data['votes']), |
48
|
|
|
$this->knPostRepository->getRpgVotesTop10() |
49
|
|
|
) |
50
|
|
|
); |
51
|
|
|
$game->setTemplateVar('USER_COUNT', $this->knPostRepository->getRpgVotesOfUser($game->getUser())); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|