|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\History\Lib; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use Stu\Component\History\HistoryTypeEnum; |
|
9
|
|
|
use Stu\Lib\Map\EntityWithLocationInterface; |
|
10
|
|
|
use Stu\Orm\Entity\Alliance; |
|
11
|
|
|
use Stu\Orm\Entity\Colony; |
|
12
|
|
|
use Stu\Orm\Entity\Location; |
|
13
|
|
|
use Stu\Orm\Entity\Spacecraft; |
|
14
|
|
|
use Stu\Orm\Repository\HistoryRepositoryInterface; |
|
15
|
|
|
|
|
16
|
|
|
final class EntryCreator implements EntryCreatorInterface |
|
17
|
|
|
{ |
|
18
|
2 |
|
public function __construct(private HistoryRepositoryInterface $historyRepository) {} |
|
19
|
|
|
|
|
20
|
|
|
#[Override] |
|
21
|
|
|
public function addEntry( |
|
22
|
|
|
string $text, |
|
23
|
|
|
int $sourceUserId, |
|
24
|
|
|
Spacecraft|Colony|Alliance $target |
|
25
|
|
|
): void { |
|
26
|
|
|
|
|
27
|
|
|
if ($target instanceof Spacecraft) { |
|
28
|
|
|
$type = $target->isStation() ? HistoryTypeEnum::STATION : HistoryTypeEnum::SHIP; |
|
|
|
|
|
|
29
|
|
|
$targetUser = $target->getUser(); |
|
|
|
|
|
|
30
|
|
|
} elseif ($target instanceof Colony) { |
|
31
|
|
|
$type = HistoryTypeEnum::COLONY; |
|
32
|
|
|
$targetUser = $target->getUser(); |
|
33
|
|
|
} else { |
|
34
|
|
|
$type = HistoryTypeEnum::ALLIANCE; |
|
35
|
|
|
$targetUser = $target->getFounder()->getUser(); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
if ($targetUser === null) { |
|
39
|
|
|
return; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$location = $target instanceof EntityWithLocationInterface |
|
43
|
|
|
? $target->getLocation() |
|
44
|
|
|
: null; |
|
45
|
|
|
|
|
46
|
|
|
$this->createEntry( |
|
47
|
|
|
$type, |
|
48
|
|
|
$text, |
|
49
|
|
|
$sourceUserId, |
|
50
|
|
|
$targetUser->getId(), |
|
51
|
|
|
$location |
|
52
|
|
|
); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
#[Override] |
|
56
|
|
|
public function createEntry( |
|
57
|
|
|
HistoryTypeEnum $type, |
|
58
|
|
|
string $text, |
|
59
|
|
|
int $sourceUserId, |
|
60
|
|
|
int $targetUserId, |
|
61
|
|
|
?Location $location = null |
|
62
|
|
|
): void { |
|
63
|
|
|
$entry = $this->historyRepository->prototype(); |
|
64
|
|
|
$entry->setText($text); |
|
65
|
|
|
$entry->setSourceUserId($sourceUserId); |
|
66
|
|
|
$entry->setTargetUserId($targetUserId); |
|
67
|
|
|
$entry->setDate(time()); |
|
68
|
|
|
$entry->setType($type); |
|
69
|
|
|
$entry->setLocation($location); |
|
70
|
|
|
|
|
71
|
|
|
$this->historyRepository->save($entry); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
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