|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Game\Lib\View\Provider; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use Stu\Component\Game\GameEnum; |
|
|
|
|
|
|
9
|
|
|
use Stu\Component\Trade\TradeEnum; |
|
|
|
|
|
|
10
|
|
|
use Stu\Lib\Session\SessionStorageInterface; |
|
11
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
12
|
|
|
use Stu\Module\Control\ViewContextTypeEnum; |
|
13
|
|
|
use Stu\Module\Trade\Lib\TradeOfferItem; |
|
14
|
|
|
use Stu\Module\Trade\Lib\TradeOfferItemInterface; |
|
15
|
|
|
use Stu\Orm\Entity\TradeOfferInterface; |
|
16
|
|
|
use Stu\Orm\Repository\CommodityRepositoryInterface; |
|
17
|
|
|
use Stu\Orm\Repository\TradeLicenseRepositoryInterface; |
|
18
|
|
|
use Stu\Orm\Repository\TradeOfferRepositoryInterface; |
|
19
|
|
|
|
|
20
|
|
|
final class TradeProvider implements ViewComponentProviderInterface |
|
21
|
|
|
{ |
|
22
|
1 |
|
public function __construct( |
|
23
|
|
|
private readonly TradeLicenseRepositoryInterface $tradeLicenseRepository, |
|
24
|
|
|
private readonly TradeOfferRepositoryInterface $tradeOfferRepository, |
|
25
|
|
|
private readonly CommodityRepositoryInterface $commodityRepository, |
|
26
|
|
|
private readonly SessionStorageInterface $sessionStorage |
|
27
|
1 |
|
) {} |
|
28
|
|
|
|
|
29
|
1 |
|
#[Override] |
|
30
|
|
|
public function setTemplateVariables(GameControllerInterface $game): void |
|
31
|
|
|
{ |
|
32
|
1 |
|
$user = $game->getUser(); |
|
33
|
1 |
|
$userId = $user->getId(); |
|
34
|
|
|
|
|
35
|
1 |
|
$isFilterActive = $game->getViewContext(ViewContextTypeEnum::FILTER_ACTIVE) ?? false; |
|
36
|
|
|
|
|
37
|
1 |
|
$commodityId = null; |
|
38
|
1 |
|
$postId = null; |
|
39
|
1 |
|
$dir = TradeEnum::FILTER_COMMODITY_IN_BOTH; |
|
40
|
1 |
|
if ($isFilterActive) { |
|
41
|
|
|
if ($this->sessionStorage->getSessionValue('trade_filter_cid')) { |
|
42
|
|
|
$commodityId = $this->sessionStorage->getSessionValue('trade_filter_cid'); |
|
43
|
|
|
} |
|
44
|
|
|
if ($this->sessionStorage->getSessionValue('trade_filter_pid')) { |
|
45
|
|
|
$postId = $this->sessionStorage->getSessionValue('trade_filter_pid'); |
|
46
|
|
|
} |
|
47
|
|
|
if ($this->sessionStorage->getSessionValue('trade_filter_dir')) { |
|
48
|
|
|
$dir = $this->sessionStorage->getSessionValue('trade_filter_dir'); |
|
49
|
|
|
} |
|
50
|
|
|
} else { |
|
51
|
1 |
|
$this->sessionStorage->deleteSessionData('trade_filter_cid'); |
|
52
|
1 |
|
$this->sessionStorage->deleteSessionData('trade_filter_pid'); |
|
53
|
1 |
|
$this->sessionStorage->deleteSessionData('trade_filter_dir'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
1 |
|
$game->setTemplateVar('COMMODITY_ID', $commodityId ?? 0); |
|
57
|
1 |
|
$game->setTemplateVar('POST_ID', $postId ?? 0); |
|
58
|
|
|
|
|
59
|
1 |
|
$tradeLicenses = $this->tradeLicenseRepository->getLicensesCountbyUser($userId); |
|
60
|
1 |
|
$game->setTemplateVar('TRADE_LICENSES', $tradeLicenses); |
|
61
|
1 |
|
$game->setTemplateVar('TRADE_LICENSE_COUNT', count($tradeLicenses)); |
|
62
|
|
|
|
|
63
|
1 |
|
$commodityList = $this->commodityRepository->getTradeable(); |
|
64
|
1 |
|
$game->setTemplateVar('SELECTABLE_COMMODITIES', $commodityList); |
|
65
|
|
|
|
|
66
|
1 |
|
$game->setTemplateVar('MAX_TRADE_LICENSE_COUNT', GameEnum::MAX_TRADELICENSE_COUNT); |
|
67
|
1 |
|
$game->setTemplateVar( |
|
68
|
1 |
|
'OFFER_LIST', |
|
69
|
1 |
|
array_map( |
|
70
|
1 |
|
fn(TradeOfferInterface $tradeOffer): TradeOfferItemInterface => new TradeOfferItem($tradeOffer, $user), |
|
71
|
1 |
|
$this->tradeOfferRepository->getByUserLicenses($userId, $commodityId, $postId, $dir) |
|
72
|
1 |
|
) |
|
73
|
1 |
|
); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
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