Test Failed
Pull Request — master (#1775)
by Nico
26:52
created

NPCLog::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 17
rs 9.9
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\NPC\View\NPCLog;
6
7
use Stu\Module\Control\GameControllerInterface;
8
use Stu\Module\Control\ViewControllerInterface;
9
use Stu\Orm\Repository\NPCLogRepositoryInterface;
10
11
final class NPCLog implements ViewControllerInterface
12
{
13
    public const VIEW_IDENTIFIER = 'SHOW_NPC_LOG';
14
15
    private NPCLogRepositoryInterface $npclogRepository;
16
17
    public function __construct(
18
        NPCLogRepositoryInterface $npclogRepository
19
    ) {
20
        $this->npclogRepository = $npclogRepository;
21
    }
22
23
    public function handle(GameControllerInterface $game): void
24
    {
25
        $game->appendNavigationPart(
26
            sprintf(
27
                '/npc/?%s=1',
28
                static::VIEW_IDENTIFIER
29
            ),
30
            _('NPC Log')
31
        );
32
33
        $logs = $this->npclogRepository->findBy([], ['id' => 'DESC'], 100);
34
35
        $game->setTemplateFile('html/npc/npclog.twig');
36
        $game->setPageTitle(_('NPC Log'));
37
        $game->setTemplateVar(
38
            'LIST',
39
            $logs
40
        );
41
    }
42
}