|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Prestige\Lib; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use Stu\Lib\Component\ComponentRegistrationInterface; |
|
9
|
|
|
use Stu\Module\Game\Component\GameComponentEnum; |
|
10
|
|
|
use Stu\Orm\Entity\DatabaseEntryInterface; |
|
11
|
|
|
use Stu\Orm\Entity\UserInterface; |
|
12
|
|
|
use Stu\Orm\Repository\PrestigeLogRepositoryInterface; |
|
13
|
|
|
use Stu\Orm\Repository\UserRepositoryInterface; |
|
14
|
|
|
|
|
15
|
|
|
final class CreatePrestigeLog implements CreatePrestigeLogInterface |
|
16
|
|
|
{ |
|
17
|
2 |
|
public function __construct( |
|
18
|
|
|
private PrestigeLogRepositoryInterface $prestigeLogRepository, |
|
19
|
|
|
private UserRepositoryInterface $userRepository, |
|
20
|
|
|
private ComponentRegistrationInterface $componentRegistration |
|
21
|
2 |
|
) {} |
|
22
|
|
|
|
|
23
|
|
|
#[Override] |
|
24
|
|
|
public function createLog(int $amount, string $description, UserInterface $user, int $date): void |
|
25
|
|
|
{ |
|
26
|
|
|
$this->createLogIntern($amount, $description, $user, $date); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
#[Override] |
|
30
|
|
|
public function createLogForDatabaseEntry(DatabaseEntryInterface $databaseEntry, UserInterface $user, int $date): void |
|
31
|
|
|
{ |
|
32
|
|
|
$amount = $databaseEntry->getCategory()->getPrestige(); |
|
33
|
|
|
$description = sprintf( |
|
34
|
|
|
'%d Prestige erhalten für die Entdeckung von "%s" in der Kategorie "%s"', |
|
35
|
|
|
$amount, |
|
36
|
|
|
$databaseEntry->getDescription(), |
|
37
|
|
|
$databaseEntry->getCategory()->getDescription() |
|
38
|
|
|
); |
|
39
|
|
|
|
|
40
|
|
|
$this->createLogIntern($amount, $description, $user, $date); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
private function createLogIntern(int $amount, string $description, UserInterface $user, int $date): void |
|
44
|
|
|
{ |
|
45
|
|
|
$prestigeLog = $this->prestigeLogRepository->prototype(); |
|
46
|
|
|
$prestigeLog->setUserId($user->getId()); |
|
47
|
|
|
$prestigeLog->setAmount($amount); |
|
48
|
|
|
$prestigeLog->setDate($date); |
|
49
|
|
|
$prestigeLog->setDescription($description); |
|
50
|
|
|
|
|
51
|
|
|
$this->prestigeLogRepository->save($prestigeLog); |
|
52
|
|
|
|
|
53
|
|
|
//update user prestige |
|
54
|
|
|
$user->setPrestige($user->getPrestige() + $prestigeLog->getAmount()); |
|
55
|
|
|
$this->userRepository->save($user); |
|
56
|
|
|
|
|
57
|
|
|
$this->componentRegistration->addComponentUpdate(GameComponentEnum::USER); |
|
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