|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Ship\View\ShowAggregationSystem; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use request; |
|
9
|
|
|
use Stu\Exception\SanityCheckException; |
|
10
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
11
|
|
|
use Stu\Module\Control\ViewControllerInterface; |
|
12
|
|
|
use Stu\Module\Commodity\CommodityTypeEnum; |
|
|
|
|
|
|
13
|
|
|
use Stu\Module\Ship\Lib\ShipLoaderInterface; |
|
14
|
|
|
use Stu\Orm\Repository\CommodityRepositoryInterface; |
|
15
|
|
|
|
|
16
|
|
|
final class ShowAggregationSystem implements ViewControllerInterface |
|
17
|
|
|
{ |
|
18
|
|
|
public const VIEW_IDENTIFIER = 'SHOW_AGGREGATION_SYSTEM_AJAX'; |
|
19
|
|
|
|
|
20
|
|
|
public function __construct( |
|
21
|
|
|
private ShipLoaderInterface $shipLoader, |
|
22
|
|
|
private CommodityRepositoryInterface $commodityRepository |
|
23
|
|
|
) {} |
|
24
|
|
|
|
|
25
|
|
|
#[Override] |
|
26
|
|
|
public function handle(GameControllerInterface $game): void |
|
27
|
|
|
{ |
|
28
|
|
|
$user = $game->getUser(); |
|
29
|
|
|
$userId = $user->getId(); |
|
30
|
|
|
|
|
31
|
|
|
$wrapper = $this->shipLoader->getWrapperByIdAndUser( |
|
32
|
|
|
request::indInt('id'), |
|
33
|
|
|
$userId, |
|
34
|
|
|
false, |
|
35
|
|
|
false |
|
36
|
|
|
); |
|
37
|
|
|
|
|
38
|
|
|
$game->setPageTitle(_('Aggregationssystem')); |
|
39
|
|
|
$game->setMacroInAjaxWindow('html/ship/aggregationsystem.twig'); |
|
40
|
|
|
|
|
41
|
|
|
$game->setTemplateVar('WRAPPER', $wrapper); |
|
42
|
|
|
|
|
43
|
|
|
$aggregationsystem = $wrapper->getAggregationSystemSystemData(); |
|
44
|
|
|
if ($aggregationsystem === null) { |
|
45
|
|
|
throw new SanityCheckException('no aggregation system installed', null, self::VIEW_IDENTIFIER); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
$commodities = CommodityTypeEnum::COMMODITY_CONVERSIONS; |
|
49
|
|
|
$mode1Commodities = array_filter($commodities, fn($entry) => $entry[3] === 1); |
|
50
|
|
|
$mode2Commodities = array_filter($commodities, fn($entry) => $entry[3] === 2); |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
$mode1Commodities = array_map(fn($entry) => [ |
|
54
|
|
|
$this->commodityRepository->find($entry[0]), |
|
55
|
|
|
$this->commodityRepository->find($entry[1]), |
|
56
|
|
|
$entry[2] |
|
57
|
|
|
], $mode1Commodities); |
|
58
|
|
|
|
|
59
|
|
|
$mode2Commodities = array_map(fn($entry) => [ |
|
60
|
|
|
$this->commodityRepository->find($entry[0]), |
|
61
|
|
|
$this->commodityRepository->find($entry[1]), |
|
62
|
|
|
$entry[2] |
|
63
|
|
|
], $mode2Commodities); |
|
64
|
|
|
|
|
65
|
|
|
$chosencommodity = $aggregationsystem->getCommodityId(); |
|
66
|
|
|
$game->setTemplateVar('MODE1_COMMODITIES', $mode1Commodities); |
|
67
|
|
|
$game->setTemplateVar('MODE2_COMMODITIES', $mode2Commodities); |
|
68
|
|
|
$game->setTemplateVar('CHOSENCOMMODITY', $chosencommodity); |
|
69
|
|
|
} |
|
70
|
|
|
} |
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