|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Component\Event\Strategy; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
6
|
|
|
use Doctrine\Common\Collections\Collection; |
|
7
|
|
|
use Stu\Component\Building\BuildingEnum; |
|
|
|
|
|
|
8
|
|
|
use Stu\Component\Colony\ColonyFunctionManagerInterface; |
|
9
|
|
|
use Stu\Component\Colony\Storage\ColonyStorageManagerInterface; |
|
10
|
|
|
use Stu\Module\Message\Lib\PrivateMessageFolderTypeEnum; |
|
11
|
|
|
use Stu\Module\Message\Lib\PrivateMessageSenderInterface; |
|
12
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
|
|
|
|
|
13
|
|
|
use Stu\Orm\Entity\EventInterface; |
|
14
|
|
|
use Stu\Orm\Repository\ModuleQueueRepositoryInterface; |
|
15
|
|
|
|
|
16
|
|
|
class SparePartGenerationEventStrategy implements EventStrategyInterface |
|
17
|
|
|
{ |
|
18
|
|
|
public function __construct( |
|
19
|
|
|
private ModuleQueueRepositoryInterface $moduleQueueRepository, |
|
20
|
|
|
private ColonyFunctionManagerInterface $colonyFunctionManager, |
|
21
|
|
|
private ColonyStorageManagerInterface $colonyStorageManager, |
|
22
|
|
|
private PrivateMessageSenderInterface $privateMessageSender |
|
23
|
|
|
) { |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function getEntitiesToLock(EventInterface $event): Collection |
|
27
|
|
|
{ |
|
28
|
|
|
return new ArrayCollection(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function processEvent(EventInterface $event): void |
|
32
|
|
|
{ |
|
33
|
|
|
foreach ($this->moduleQueueRepository->findAll() as $queue) { |
|
34
|
|
|
$buildingFunction = $queue->getBuildingFunction(); |
|
35
|
|
|
|
|
36
|
|
|
if ( |
|
37
|
|
|
$buildingFunction === BuildingEnum::BUILDING_FUNCTION_FABRICATION_HALL || |
|
38
|
|
|
$buildingFunction === BuildingEnum::BUILDING_FUNCTION_TECH_CENTER |
|
39
|
|
|
) { |
|
40
|
|
|
$colony = $queue->getColony(); |
|
41
|
|
|
|
|
42
|
|
|
if ($this->colonyFunctionManager->hasActiveFunction($colony, $buildingFunction)) { |
|
43
|
|
|
$this->colonyStorageManager->upperStorage( |
|
44
|
|
|
$colony, |
|
45
|
|
|
$queue->getModule()->getCommodity(), |
|
46
|
|
|
$queue->getAmount() |
|
47
|
|
|
); |
|
48
|
|
|
|
|
49
|
|
|
$this->privateMessageSender->send( |
|
50
|
|
|
UserEnum::USER_NOONE, |
|
51
|
|
|
$colony->getUser()->getId(), |
|
52
|
|
|
sprintf( |
|
53
|
|
|
_('Es wurden %d %s hergestellt'), |
|
54
|
|
|
$queue->getAmount(), |
|
55
|
|
|
$queue->getModule()->getName() |
|
56
|
|
|
), |
|
57
|
|
|
PrivateMessageFolderTypeEnum::SPECIAL_COLONY |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
|
|
$this->moduleQueueRepository->delete($queue); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
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