1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stu\Module\Colony\Lib\Gui\Component; |
4
|
|
|
|
5
|
|
|
use request; |
6
|
|
|
use RuntimeException; |
7
|
|
|
use Stu\Lib\Colony\PlanetFieldHostInterface; |
8
|
|
|
use Stu\Module\Colony\View\ShowModuleFab\ModuleFabricationListItemTal; |
9
|
|
|
use Stu\Module\Control\GameControllerInterface; |
10
|
|
|
use Stu\Orm\Entity\ColonyInterface; |
11
|
|
|
use Stu\Orm\Repository\BuildingFunctionRepositoryInterface; |
12
|
|
|
use Stu\Orm\Repository\ModuleBuildingFunctionRepositoryInterface; |
13
|
|
|
use Stu\Orm\Repository\ModuleQueueRepositoryInterface; |
14
|
|
|
|
15
|
|
|
final class ModuleFabProvider implements GuiComponentProviderInterface |
16
|
|
|
{ |
17
|
|
|
private ModuleBuildingFunctionRepositoryInterface $moduleBuildingFunctionRepository; |
18
|
|
|
|
19
|
|
|
private BuildingFunctionRepositoryInterface $buildingFunctionRepository; |
20
|
|
|
|
21
|
|
|
private ModuleQueueRepositoryInterface $moduleQueueRepository; |
22
|
|
|
|
23
|
|
|
public function __construct( |
24
|
|
|
ModuleBuildingFunctionRepositoryInterface $moduleBuildingFunctionRepository, |
25
|
|
|
BuildingFunctionRepositoryInterface $buildingFunctionRepository, |
26
|
|
|
ModuleQueueRepositoryInterface $moduleQueueRepository |
27
|
|
|
) { |
28
|
|
|
$this->moduleBuildingFunctionRepository = $moduleBuildingFunctionRepository; |
29
|
|
|
$this->buildingFunctionRepository = $buildingFunctionRepository; |
30
|
|
|
$this->moduleQueueRepository = $moduleQueueRepository; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** @param ColonyInterface $host */ |
34
|
|
|
public function setTemplateVariables( |
35
|
|
|
PlanetFieldHostInterface $host, |
36
|
|
|
GameControllerInterface $game |
37
|
|
|
): void { |
38
|
|
|
|
39
|
|
|
$func = $this->buildingFunctionRepository->find(request::getIntFatal('func')); |
40
|
|
|
if ($func === null) { |
41
|
|
|
throw new RuntimeException('parameter func is missing'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$modules = $this->moduleBuildingFunctionRepository->getByBuildingFunctionAndUser( |
45
|
|
|
$func->getFunction(), |
46
|
|
|
$game->getUser()->getId() |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
$list = []; |
50
|
|
|
foreach ($modules as $module) { |
51
|
|
|
$list[] = new ModuleFabricationListItemTal( |
52
|
|
|
$this->moduleQueueRepository, |
53
|
|
|
$module->getModule(), |
54
|
|
|
$host |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$game->setTemplateVar('FUNC', $func); |
59
|
|
|
$game->setTemplateVar('MODULE_LIST', $list); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|