Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ USER_ID=1000
GROUP_ID=1000

POSTGRES_DB=
DB_PASSWORD=

###> symfony/framework-bundle ###
APP_ENV=dev
Expand Down
44 changes: 0 additions & 44 deletions .env.dist

This file was deleted.

22 changes: 11 additions & 11 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ services:
- caddy_config:/config
ports:
# HTTP
- target: 80
published: ${HTTP_PORT:-80}
protocol: tcp
- target: 80
published: ${HTTP_PORT:-80}
protocol: tcp
# HTTPS
- target: 443
published: ${HTTPS_PORT:-443}
protocol: tcp
- target: 443
published: ${HTTPS_PORT:-443}
protocol: tcp
# HTTP/3
- target: 443
published: ${HTTP3_PORT:-443}
protocol: udp
- target: 443
published: ${HTTP3_PORT:-443}
protocol: udp
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:80/"]
test: ['CMD', 'curl', '--fail', 'http://localhost:80/']
interval: 10s
timeout: 5s
retries: 5
start_period: 10s

# Mercure is installed as a Caddy module, prevent the Flex recipe from installing another service
###> symfony/mercure-bundle ###
###< symfony/mercure-bundle ###
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use App\Application\Command\Game\CreateGameCommand;
use App\Application\Command\Game\CreateGameWithCacheCheckCommand;
use App\Application\Exception\Game\CannotCreateGameException;
use App\Application\Helper\MessageBusHelper;
use App\Application\Query\Game\GetGameBySlugOnApiQuery;
use App\Domain\Model\Game\ApiGame;
use Psr\Cache\InvalidArgumentException;
use Psr\Log\LoggerInterface;
Expand All @@ -21,6 +23,7 @@ class CreateGameWithCacheCheckCommandHandler
public function __construct(
private readonly CacheInterface $cache,
private readonly MessageBusInterface $messageBus,
private readonly MessageBusHelper $messageBusHelper,
private readonly LoggerInterface $logger,
) {
}
Expand All @@ -40,7 +43,19 @@ function (): ?ApiGame {
);

if (null === $apiGame) {
return;
$gameEnvelope = $this->messageBus->dispatch(
new GetGameBySlugOnApiQuery($command->gameSlug),
);

/** @var ?ApiGame $apiGame */
$apiGame = $this->messageBusHelper->getContentFromEnvelope(
$gameEnvelope,
'Failed to fetch game from API',
);
}

if (null === $apiGame) {
throw new CannotCreateGameException('Failed to fetch game from API');
}

try {
Expand All @@ -53,7 +68,7 @@ function (): ?ApiGame {
publisher: $apiGame->getPublisher(),
developer: $apiGame->getDeveloper(),
description: $apiGame->getDescription(),
)
),
);
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function __invoke(CreateReportFromDtoCommand $command): void
isNativeResolutionImprovedDocked: $command->formInputDto->isNativeResolutionDocked,
hasImprovedLoadingTimes: $command->formInputDto->hasImprovedLoadingTimes,
gameStatus: $command->formInputDto->gameStatus,
isPatched: $command->formInputDto->isPatched,
);

$this->reportRepository->save($newReport);
Expand Down
12 changes: 12 additions & 0 deletions src/Application/Query/Game/GetGameBySlugOnApiQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace App\Application\Query\Game;

readonly class GetGameBySlugOnApiQuery
{
public function __construct(public string $slug)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace App\Application\QueryHandler\Game;

use App\Application\Query\Game\GetGameBySlugOnApiQuery;
use App\Domain\Model\Game\ApiGame;
use App\Domain\Repository\Game\ApiGameRepositoryInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler]
class GetGameBySlugOnApiQueryHandler
{
public function __construct(
private ApiGameRepositoryInterface $apiGameRepository,
) {
}

public function __invoke(GetGameBySlugOnApiQuery $query): ?ApiGame
{
return $this->apiGameRepository->getGameBySlug($query->slug);
}
}
2 changes: 0 additions & 2 deletions src/Domain/Factory/Game/GameFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public static function create(
string $description,
string $releaseDate,
string $imageCover,
bool $isPatched = false,
bool $isActive = true,
?Publisher $publisher = null,
?Developer $developer = null,
Expand All @@ -34,7 +33,6 @@ public static function create(
description: $description,
releaseDate: $releaseDate,
imageCover: $imageCover,
isPatched: $isPatched,
isActive: $isActive,
publisher: $publisher,
developer: $developer,
Expand Down
2 changes: 2 additions & 0 deletions src/Domain/Factory/Report/ReportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static function create(
bool $isNativeResolutionImprovedDocked = false,
bool $hasImprovedLoadingTimes = true,
ReportGameStatusEnum $gameStatus = ReportGameStatusEnum::OK,
bool $isPatched = false,
int $upvoteCount = 0,
bool $isVisible = true,
): Report {
Expand All @@ -39,6 +40,7 @@ public static function create(
hasImprovedLoadingTimes: $hasImprovedLoadingTimes,
isSwitch2Edition: $isSwitch2Edition,
gameStatus: $gameStatus,
isPatched: $isPatched,
upvoteCount: $upvoteCount,
isVisible: $isVisible,
);
Expand Down
13 changes: 0 additions & 13 deletions src/Domain/Model/Game/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public function __construct(
private ?string $description = null,
private ?string $releaseDate = null,
private ?string $imageCover = null,
private bool $isPatched = false,
private bool $isActive = true,
private ?Publisher $publisher = null,
private ?Developer $developer = null,
Expand Down Expand Up @@ -91,18 +90,6 @@ public function setImageCover(string $imageCover): self
return $this;
}

public function isPatched(): bool
{
return $this->isPatched;
}

public function setIsPatched(bool $isPatched): self
{
$this->isPatched = $isPatched;

return $this;
}

public function isActive(): bool
{
return $this->isActive;
Expand Down
36 changes: 15 additions & 21 deletions src/Domain/Model/Report/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

use App\Domain\Model\Common\ModelInterface;
use App\Domain\Model\Game\Game;
use App\Domain\Trait\IdTrait;
use App\Domain\Trait\TimestampableTrait;
use App\Infrastructure\Enum\ReportGameStatusEnum;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Uid\Uuid;

class Report implements ModelInterface
{
use IdTrait;
use TimestampableTrait;
private ?string $id = null;

public function __construct(
private Game $game,
Expand All @@ -30,25 +30,14 @@ public function __construct(
private bool $hasImprovedLoadingTimes = false,
private bool $isSwitch2Edition = false,
private ReportGameStatusEnum $gameStatus = ReportGameStatusEnum::OK,
private bool $isPatched = false,
private int $upvoteCount = 0,
private bool $isVisible = true,
/** @var Collection<int, ReportComment> $reportComments */
private Collection $reportComments = new ArrayCollection(),
) {
}

public function getId(): ?string
{
return $this->id;
}

public function setId(string $id): self
{
$this->id = $id;

return $this;
}

public function getGame(): Game
{
return $this->game;
Expand Down Expand Up @@ -123,6 +112,18 @@ public function setGameStatus(ReportGameStatusEnum $gameStatus): self
return $this;
}

public function isPatched(): bool
{
return $this->isPatched;
}

public function setIsPatched(bool $isPatched): self
{
$this->isPatched = $isPatched;

return $this;
}

public function isNativeResolutionPortable(): bool
{
return $this->isNativeResolutionPortable;
Expand Down Expand Up @@ -249,11 +250,4 @@ public function removeReportComment(ReportComment $reportComment): self

return $this;
}

public function setDefaultId(): self
{
$this->id = Uuid::v7()->toRfc4122();

return $this;
}
}
4 changes: 0 additions & 4 deletions src/Domain/Resources/config/validator/Game.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<constraint name="NotBlank"/>
</property>

<property name="isPatched">
<constraint name="NotNull"/>
</property>

<property name="isActive">
<constraint name="NotNull"/>
</property>
Expand Down
4 changes: 4 additions & 0 deletions src/Domain/Resources/config/validator/Report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
</constraint>
</property>

<property name="isPatched">
<constraint name="NotNull"/>
</property>

<property name="isVisible">
<constraint name="NotNull"/>
</property>
Expand Down
Loading