|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Control\Render; |
|
6
|
|
|
|
|
7
|
|
|
use Noodlehaus\ConfigInterface; |
|
8
|
|
|
use Override; |
|
|
|
|
|
|
9
|
|
|
use Stu\Component\Game\GameEnum; |
|
|
|
|
|
|
10
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
11
|
|
|
use Stu\Module\Game\Lib\Component\ComponentLoaderInterface; |
|
12
|
|
|
use Stu\Module\Twig\TwigPageInterface; |
|
13
|
|
|
use Stu\Orm\Entity\UserInterface; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Executes the render chain for the site template |
|
17
|
|
|
* |
|
18
|
|
|
* Also registers a set of default variables for rendering |
|
19
|
|
|
*/ |
|
20
|
|
|
final class GameTwigRenderer implements GameTwigRendererInterface |
|
21
|
|
|
{ |
|
22
|
4 |
|
public function __construct(private ConfigInterface $config, private ComponentLoaderInterface $componentLoader) |
|
23
|
|
|
{ |
|
24
|
4 |
|
} |
|
25
|
|
|
|
|
26
|
|
|
#[Override] |
|
27
|
|
|
public function render( |
|
28
|
|
|
GameControllerInterface $game, |
|
29
|
|
|
?UserInterface $user, |
|
30
|
|
|
TwigPageInterface $twigPage |
|
31
|
|
|
): string { |
|
32
|
|
|
|
|
33
|
|
|
$this->componentLoader->loadComponentUpdates($game); |
|
34
|
|
|
$this->componentLoader->loadRegisteredComponents($twigPage, $game); |
|
35
|
|
|
$this->setGameVariables($twigPage, $game); |
|
36
|
|
|
$this->setUserVariables($user, $twigPage); |
|
37
|
|
|
|
|
38
|
|
|
$twigPage->setVar('WIKI', $this->config->get('wiki.base_url')); |
|
39
|
|
|
$twigPage->setVar('FORUM', $this->config->get('board.base_url')); |
|
40
|
|
|
$twigPage->setVar('CHAT', $this->config->get('discord.url')); |
|
41
|
|
|
|
|
42
|
|
|
return $twigPage->render(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
private function setGameVariables(TwigPageInterface $twigPage, GameControllerInterface $game): void |
|
46
|
|
|
{ |
|
47
|
|
|
$twigPage->setVar('MACRO', $game->getMacro()); |
|
48
|
|
|
$twigPage->setVar('NAVIGATION', $game->getNavigation()); |
|
49
|
|
|
$twigPage->setVar('PAGETITLE', $game->getPageTitle()); |
|
50
|
|
|
$twigPage->setVar('INFORMATION', $game->getInformation()); |
|
51
|
|
|
$twigPage->setVar('TARGET_LINK', $game->getTargetLink()); |
|
52
|
|
|
$twigPage->setVar('ACHIEVEMENTS', $game->getAchievements()); |
|
53
|
|
|
$twigPage->setVar('EXECUTEJSBEFORERENDER', $game->getExecuteJS(GameEnum::JS_EXECUTION_BEFORE_RENDER)); |
|
54
|
|
|
$twigPage->setVar('EXECUTEJSAFTERRENDER', $game->getExecuteJS(GameEnum::JS_EXECUTION_AFTER_RENDER)); |
|
55
|
|
|
$twigPage->setVar('EXECUTEJSAJAXUPDATE', $game->getExecuteJS(GameEnum::JS_EXECUTION_AJAX_UPDATE)); |
|
56
|
|
|
$twigPage->setVar('JAVASCRIPTPATH', $game->getJavascriptPath(), true); |
|
57
|
|
|
$twigPage->setVar('ISNPC', $game->isNpc()); |
|
58
|
|
|
$twigPage->setVar('ISADMIN', $game->isAdmin()); |
|
59
|
|
|
$twigPage->setVar('BENCHMARK', $game->getBenchmarkResult()); |
|
60
|
|
|
$twigPage->setVar('GAME_STATS', $game->getGameStats()); |
|
61
|
|
|
|
|
62
|
|
|
if ($game->hasUser()) { |
|
63
|
|
|
$twigPage->setVar('SESSIONSTRING', $game->getSessionString(), true); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
private function setUserVariables(?UserInterface $user, TwigPageInterface $twigPage): void |
|
68
|
|
|
{ |
|
69
|
|
|
if ($user === null) { |
|
70
|
|
|
$twigPage->setVar('USER', null); |
|
71
|
|
|
} else { |
|
72
|
|
|
$twigPage->setVar('USER', new UserContainer( |
|
73
|
|
|
$user->getId(), |
|
74
|
|
|
$user->getAvatar(), |
|
75
|
|
|
$user->getName(), |
|
76
|
|
|
$user->getFactionId(), |
|
77
|
|
|
$user->getCss(), |
|
78
|
|
|
$user->hasStationsNavigation(), |
|
79
|
|
|
$user->getDeals() |
|
80
|
|
|
)); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths