1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stu\Module\Colony\Lib\Gui\Component; |
4
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
6
|
|
|
use request; |
7
|
|
|
use Stu\Component\Building\BuildMenuEnum; |
8
|
|
|
use Stu\Component\Game\GameEnum; |
|
|
|
|
9
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
|
|
|
10
|
|
|
use Stu\Orm\Repository\BuildingRepositoryInterface; |
11
|
|
|
use Stu\Orm\Repository\PlanetFieldRepositoryInterface; |
12
|
|
|
|
13
|
|
|
final class BuildmenuProvider implements PlanetFieldHostComponentInterface |
14
|
|
|
{ |
15
|
1 |
|
public function __construct(private BuildingRepositoryInterface $buildingRepository, private PlanetFieldRepositoryInterface $planetFieldRepository) {} |
16
|
|
|
|
17
|
1 |
|
#[Override] |
18
|
|
|
public function setTemplateVariables( |
19
|
|
|
$entity, |
20
|
|
|
GameControllerInterface $game |
21
|
|
|
): void { |
22
|
1 |
|
$fieldType = $this->getFieldType(); |
23
|
1 |
|
if ($fieldType !== null) { |
24
|
1 |
|
$game->addExecuteJS(sprintf('fieldType = %d;', $fieldType), GameEnum::JS_EXECUTION_AJAX_UPDATE); |
25
|
|
|
} else { |
26
|
|
|
$game->addExecuteJS('fieldType = null;', GameEnum::JS_EXECUTION_AJAX_UPDATE); |
27
|
|
|
} |
28
|
|
|
|
29
|
1 |
|
foreach (BuildMenuEnum::cases() as $menu) { |
30
|
|
|
|
31
|
1 |
|
$id = $menu->value; |
32
|
1 |
|
$menus[$id]['name'] = $menu->getDescription(); |
33
|
1 |
|
$menus[$id]['buildings'] = $this->buildingRepository->getBuildmenuBuildings( |
34
|
1 |
|
$entity, |
35
|
1 |
|
$game->getUser()->getId(), |
36
|
1 |
|
$menu, |
37
|
1 |
|
0, |
38
|
1 |
|
request::has('cid') ? request::getIntFatal('cid') : null, |
39
|
1 |
|
$fieldType |
40
|
1 |
|
); |
41
|
|
|
} |
42
|
|
|
|
43
|
1 |
|
$game->setTemplateVar('BUILD_MENUS', $menus); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
1 |
|
private function getFieldType(): ?int |
47
|
|
|
{ |
48
|
1 |
|
if (!request::has('fid')) { |
49
|
|
|
return null; |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
$field = $this->planetFieldRepository->find(request::getIntFatal('fid')); |
53
|
1 |
|
if ($field === null) { |
54
|
|
|
return null; |
55
|
|
|
} |
56
|
|
|
|
57
|
1 |
|
return $field->getFieldType(); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
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