|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Game\Component; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use Stu\Component\Player\UserAwardEnum; |
|
|
|
|
|
|
9
|
|
|
use Stu\Lib\Component\ComponentInterface; |
|
10
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
11
|
|
|
use Stu\Module\Message\Lib\PrivateMessageFolderTypeEnum; |
|
12
|
|
|
use Stu\Module\Message\Lib\PrivateMessageUiFactoryInterface; |
|
13
|
|
|
use Stu\Orm\Entity\PrivateMessageFolderInterface; |
|
14
|
|
|
use Stu\Orm\Entity\UserInterface; |
|
15
|
|
|
use Stu\Orm\Repository\PrivateMessageFolderRepositoryInterface; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Renders the pm folders in the header |
|
19
|
|
|
*/ |
|
20
|
|
|
final class MessageFolderComponent implements ComponentInterface |
|
21
|
|
|
{ |
|
22
|
3 |
|
public function __construct( |
|
23
|
|
|
private PrivateMessageFolderRepositoryInterface $privateMessageFolderRepository, |
|
24
|
|
|
private PrivateMessageUiFactoryInterface $commUiFactory |
|
25
|
3 |
|
) {} |
|
26
|
|
|
|
|
27
|
6 |
|
#[Override] |
|
28
|
|
|
public function setTemplateVariables(GameControllerInterface $game): void |
|
29
|
|
|
{ |
|
30
|
6 |
|
$user = $game->getUser(); |
|
31
|
|
|
|
|
32
|
6 |
|
$pmFolder = [ |
|
33
|
6 |
|
PrivateMessageFolderTypeEnum::SPECIAL_MAIN, |
|
34
|
6 |
|
PrivateMessageFolderTypeEnum::SPECIAL_SHIP, |
|
35
|
6 |
|
PrivateMessageFolderTypeEnum::SPECIAL_STATION, |
|
36
|
6 |
|
PrivateMessageFolderTypeEnum::SPECIAL_COLONY, |
|
37
|
6 |
|
PrivateMessageFolderTypeEnum::SPECIAL_TRADE, |
|
38
|
6 |
|
PrivateMessageFolderTypeEnum::SPECIAL_SYSTEM |
|
39
|
6 |
|
]; |
|
40
|
6 |
|
$folder = []; |
|
41
|
|
|
|
|
42
|
6 |
|
foreach ($pmFolder as $folderType) { |
|
43
|
|
|
if ( |
|
44
|
6 |
|
$folderType === PrivateMessageFolderTypeEnum::SPECIAL_STATION |
|
45
|
6 |
|
&& !$this->hasStationsPmCategory($user) |
|
46
|
|
|
) { |
|
47
|
5 |
|
continue; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** @var PrivateMessageFolderInterface $specialFolder */ |
|
51
|
6 |
|
$specialFolder = $this->privateMessageFolderRepository->getByUserAndSpecial($user->getId(), $folderType); |
|
52
|
|
|
|
|
53
|
6 |
|
$folder[$folderType->value] = $this->commUiFactory->createPrivateMessageFolderItem($specialFolder); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
6 |
|
$game->setTemplateVar('PM', $folder); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
6 |
|
private function hasStationsPmCategory(UserInterface $user): bool |
|
60
|
|
|
{ |
|
61
|
6 |
|
if ($user->isNpc()) { |
|
62
|
1 |
|
return true; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
5 |
|
return $user->hasAward(UserAwardEnum::RESEARCHED_STATIONS); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
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