Private
Public Access
1
0

chg: pkg: upgrade the doctrine related back-end pkgs to the latest available version #7

This commit is contained in:
2026-04-20 09:05:36 +02:00
parent 5f856e4d70
commit 175581cdd5
30 changed files with 456 additions and 1015 deletions

View File

@@ -80,8 +80,8 @@ class RpcManager implements RpcManagerInterface
$revealedCells = $this->aggregateRevealedCells($playedGame);
try {
$redPoints = $playedGame->getRedPoints() ?? 0;
$bluePoints = $playedGame->getBluePoints() ?? 0;
$redPoints = $playedGame->redPoints ?? 0;
$bluePoints = $playedGame->bluePoints ?? 0;
$gameFinished = $redPoints > 25 || $bluePoints > 25;
return base64_encode(json_encode([
@@ -91,10 +91,10 @@ class RpcManager implements RpcManagerInterface
'mostRecentStep' => $this->getMostRecentStep($playedGame),
'redPoints' => $redPoints,
'bluePoints' => $bluePoints,
'redBonusPoints' => $playedGame->getRedBonusPoints() ?? 0,
'blueBonusPoints' => $playedGame->getBlueBonusPoints() ?? 0,
'redBonusStats' => $playedGame->getRedBonusStats() ?? [],
'blueBonusStats' => $playedGame->getBlueBonusStats() ?? [],
'redBonusPoints' => $playedGame->redBonusPoints ?? 0,
'blueBonusPoints' => $playedGame->blueBonusPoints ?? 0,
'redBonusStats' => $playedGame->redBonusStats ?? [],
'blueBonusStats' => $playedGame->blueBonusStats ?? [],
'gameFinished' => $gameFinished,
], JSON_THROW_ON_ERROR));
} catch (JsonException $e) {
@@ -131,19 +131,19 @@ class RpcManager implements RpcManagerInterface
try {
foreach ($grid2d as $row) {
$gridRow = new GridRow();
$gridRow->setGridCol($row);
$gridRow->setGrid($grid);
$gridRow->gridCol = $row;
$gridRow->grid = $grid;
$this->em->persist($gridRow);
}
$grid->setPlayedGame($playedGame);
$grid->playedGame = $playedGame;
$this->em->persist($grid);
$playedGame->setGameAssoc($gameAssoc);
$playedGame->setUuid(Uuid::fromString($gameAssoc));
$playedGame->setGrid($grid);
$playedGame->setCreated(new DateTime());
$playedGame->setUpdated(new DateTime());
$playedGame->gameAssoc = $gameAssoc;
$playedGame->uuid = Uuid::fromString($gameAssoc);
$playedGame->grid = $grid;
$playedGame->created = new DateTime();
$playedGame->updated = new DateTime();
$this->em->persist($playedGame);
$this->em->flush();
@@ -212,12 +212,12 @@ class RpcManager implements RpcManagerInterface
{
$all = [];
foreach ($playedGame->getSteps() as $step) {
if (null === $step->getRevealedCells()) {
foreach ($playedGame->steps as $step) {
if (null === $step->revealedCells) {
continue;
}
$player = $step->getPlayer();
foreach ($step->getRevealedCells() as $cell) {
$player = $step->player;
foreach ($step->revealedCells as $cell) {
$all[] = array_merge($cell, ['player' => $player]);
}
}
@@ -250,19 +250,19 @@ class RpcManager implements RpcManagerInterface
}
return [
'player' => $step->getPlayer(),
'row' => (int)$step->getRow(),
'col' => (int)$step->getCol(),
'player' => $step->player,
'row' => (int)$step->row,
'col' => (int)$step->col,
];
}
private function getUserCollection(PlayedGame $playedGame): array
{
return [
'red' => null !== $playedGame->getRed() ? $playedGame->getRed()->getUsername() : '',
'blue' => null !== $playedGame->getBlue() ? $playedGame->getBlue()->getUsername() : '',
'redAnon' => null !== $playedGame->getRedAnon() ? $playedGame->getRedAnon()->getUserName() : '',
'blueAnon' => null !== $playedGame->getBlueAnon() ? $playedGame->getBlueAnon()->getUserName() : '',
'red' => null !== $playedGame->red ? $playedGame->red->getUsername() : '',
'blue' => null !== $playedGame->blue ? $playedGame->blue->getUsername() : '',
'redAnon' => null !== $playedGame->redAnon ? $playedGame->redAnon->userName : '',
'blueAnon' => null !== $playedGame->blueAnon ? $playedGame->blueAnon->userName : '',
];
}
}

View File

@@ -96,7 +96,7 @@ readonly class TopicManager implements TopicManagerInterface
// ── Lobby updates ──────────────────────────────────────────────────
if ($count === 1) {
// One player waiting — mark as active and announce to the lobby
$playedGame->setUpdated(new DateTime());
$playedGame->updated = new DateTime();
$this->em->persist($playedGame);
$this->em->flush();
@@ -106,7 +106,7 @@ readonly class TopicManager implements TopicManagerInterface
'action' => 'join',
'gameAssoc' => $gameAssoc,
'name' => $displayName,
'since' => $playedGame->getCreated()?->format(DateTimeInterface::ATOM) ?? '',
'since' => $playedGame->created?->format(DateTimeInterface::ATOM) ?? '',
]);
} elseif ($count === 2) {
// Both players joined — remove from lobby
@@ -122,7 +122,7 @@ readonly class TopicManager implements TopicManagerInterface
if (null !== $playedGame) {
$users = $this->getUserCollection($playedGame);
if ($this->getPlayerCount($users) === 1) {
$playedGame->setUpdated(new DateTime('2000-01-01 00:00:00'));
$playedGame->updated = new DateTime('2000-01-01 00:00:00');
$this->em->persist($playedGame);
$this->em->flush();
$this->publishToLobby(['action' => 'leave', 'gameAssoc' => $gameAssoc]);
@@ -194,8 +194,8 @@ readonly class TopicManager implements TopicManagerInterface
$minesFound = count(array_filter($revealedCells, static fn($c) => 'm' === $c['value']));
$safeCellsFound = count(array_filter($revealedCells, static fn($c) => 'm' !== $c['value']));
$redPoints = ($playedGame->getRedPoints() ?? 0) + ('red' === $player ? $minesFound : 0);
$bluePoints = ($playedGame->getBluePoints() ?? 0) + ('blue' === $player ? $minesFound : 0);
$redPoints = ($playedGame->redPoints ?? 0) + ('red' === $player ? $minesFound : 0);
$bluePoints = ($playedGame->bluePoints ?? 0) + ('blue' === $player ? $minesFound : 0);
$gameOver = $redPoints > 25 || $bluePoints > 25;
/** Calculate bonus points and stats */
@@ -266,7 +266,7 @@ readonly class TopicManager implements TopicManagerInterface
private function loadGrid(string $gameAssoc): array
{
$playedGame = $this->getPlayedGame($gameAssoc);
$gridEntity = $playedGame?->getGrid();
$gridEntity = $playedGame?->grid;
if (null === $gridEntity) {
return [];
@@ -274,8 +274,8 @@ readonly class TopicManager implements TopicManagerInterface
$grid = [];
/** @var GridRow $row */
foreach ($gridEntity->getGridRow() as $row) {
$grid[] = $row->getGridCol();
foreach ($gridEntity->gridRow as $row) {
$grid[] = $row->gridCol;
}
return $grid;
@@ -293,7 +293,7 @@ readonly class TopicManager implements TopicManagerInterface
int $bluePoints
): array {
/** Initialize or load existing bonus stats */
$redBonusStats = $playedGame->getRedBonusStats() ?? [
$redBonusStats = $playedGame->redBonusStats ?? [
'blindHits' => 0,
'chainBest' => 0,
'chainCurrent' => 0,
@@ -301,7 +301,7 @@ readonly class TopicManager implements TopicManagerInterface
'edgeMines' => 0,
'biggestReveal' => 0,
];
$blueBonusStats = $playedGame->getBlueBonusStats() ?? [
$blueBonusStats = $playedGame->blueBonusStats ?? [
'blindHits' => 0,
'chainBest' => 0,
'chainCurrent' => 0,
@@ -310,8 +310,8 @@ readonly class TopicManager implements TopicManagerInterface
'biggestReveal' => 0,
];
$redBonusPoints = $playedGame->getRedBonusPoints() ?? 0;
$blueBonusPoints = $playedGame->getBlueBonusPoints() ?? 0;
$redBonusPoints = $playedGame->redBonusPoints ?? 0;
$blueBonusPoints = $playedGame->blueBonusPoints ?? 0;
$isRed = 'red' === $player;
$currentStats = $isRed ? $redBonusStats : $blueBonusStats;
@@ -376,10 +376,10 @@ readonly class TopicManager implements TopicManagerInterface
}
/** Persist updated stats to the database */
$playedGame->setRedBonusStats($redBonusStats);
$playedGame->setBlueBonusStats($blueBonusStats);
$playedGame->setRedBonusPoints($redBonusPoints);
$playedGame->setBlueBonusPoints($blueBonusPoints);
$playedGame->redBonusStats = $redBonusStats;
$playedGame->blueBonusStats = $blueBonusStats;
$playedGame->redBonusPoints = $redBonusPoints;
$playedGame->blueBonusPoints = $blueBonusPoints;
$this->em->persist($playedGame);
return [
@@ -538,8 +538,8 @@ readonly class TopicManager implements TopicManagerInterface
private function buildRevealedMap(PlayedGame $playedGame): array
{
$map = [];
foreach ($playedGame->getSteps() as $step) {
foreach ($step->getRevealedCells() ?? [] as $cell) {
foreach ($playedGame->steps as $step) {
foreach ($step->revealedCells ?? [] as $cell) {
$map[$cell['row'] . ',' . $cell['col']] = true;
}
}
@@ -583,7 +583,7 @@ readonly class TopicManager implements TopicManagerInterface
private function saveResignToDb(string $gameAssoc, string $color): void
{
$playedGame = $this->getPlayedGame($gameAssoc);
$playedGame->setResign($color);
$playedGame->resign = $color;
$this->em->persist($playedGame);
$this->em->flush();
}
@@ -601,32 +601,32 @@ readonly class TopicManager implements TopicManagerInterface
$playedGame = $this->getPlayedGame($gameAssoc);
$step = new Step();
$step->setRow($event['coords'][0]);
$step->setCol($event['coords'][1]);
$step->setWBomb((bool)$event['bomb']);
$step->setPlayer($player);
$step->setRevealedCells($revealedCells);
$step->setPlayedGame($playedGame);
$step->setCreated(new DateTime());
$step->row = $event['coords'][0];
$step->col = $event['coords'][1];
$step->wBomb = (bool)$event['bomb'];
$step->player = $player;
$step->revealedCells = $revealedCells;
$step->playedGame = $playedGame;
$step->created = new DateTime();
$this->em->persist($step);
$playedGame->setRedPoints($redPoints);
$playedGame->setBluePoints($bluePoints);
$playedGame->redPoints = $redPoints;
$playedGame->bluePoints = $bluePoints;
if ((bool)$event['bomb']) {
if ('red' === $player) {
$playedGame->setRedExplodedBomb(true);
$playedGame->redExplodedBomb = true;
} elseif ('blue' === $player) {
$playedGame->setBlueExplodedBomb(true);
$playedGame->blueExplodedBomb = true;
}
}
$playedGame->setUpdated(new DateTime());
$playedGame->updated = new DateTime();
/** Bonus data is already persisted in calculateBonuses, but we ensure it's up to date */
if (!empty($bonusData)) {
$playedGame->setRedBonusPoints($bonusData['redBonusPoints']);
$playedGame->setBlueBonusPoints($bonusData['blueBonusPoints']);
$playedGame->setRedBonusStats($bonusData['redBonusStats']);
$playedGame->setBlueBonusStats($bonusData['blueBonusStats']);
$playedGame->redBonusPoints = $bonusData['redBonusPoints'];
$playedGame->blueBonusPoints = $bonusData['blueBonusPoints'];
$playedGame->redBonusStats = $bonusData['redBonusStats'];
$playedGame->blueBonusStats = $bonusData['blueBonusStats'];
}
$this->em->persist($playedGame);
@@ -658,11 +658,11 @@ readonly class TopicManager implements TopicManagerInterface
try {
if ($count === 1) {
$random = random_int(0, 1);
!$random ? $playedGame->setRed($user) : $playedGame->setBlue($user);
!$random ? $playedGame->red = $user : $playedGame->blue = $user;
} else {
null === $playedGame->getRed() && null === $playedGame->getRedAnon()
? $playedGame->setRed($user)
: $playedGame->setBlue($user);
null === $playedGame->red && null === $playedGame->redAnon
? $playedGame->red = $user
: $playedGame->blue = $user;
}
} catch (Exception $e) {
$this->logger->error($e->getMessage());
@@ -673,21 +673,21 @@ readonly class TopicManager implements TopicManagerInterface
{
try {
$anon = new Gamer();
$anon->setUserName($userName);
$anon->setIp($this->requestStack->getCurrentRequest()->getClientIp());
$anon->setCountry($this->extractCountry());
$anon->setUserAgent($this->requestStack->getCurrentRequest()->headers->get('User-Agent'));
$anon->setConnTimestamp(new DateTime());
$anon->userName = $userName;
$anon->ip = $this->requestStack->getCurrentRequest()->getClientIp();
$anon->country = $this->extractCountry();
$anon->userAgent = $this->requestStack->getCurrentRequest()->headers->get('User-Agent');
$anon->connTimestamp = new DateTime();
$this->em->persist($anon);
if ($count === 1) {
$random = random_int(0, 1);
!$random ? $playedGame->setRedAnon($anon) : $playedGame->setBlueAnon($anon);
!$random ? $playedGame->redAnon = $anon : $playedGame->blueAnon = $anon;
} else {
null === $playedGame->getRed() && null === $playedGame->getRedAnon()
? $playedGame->setRedAnon($anon)
: $playedGame->setBlueAnon($anon);
null === $playedGame->red && null === $playedGame->redAnon
? $playedGame->redAnon = $anon
: $playedGame->blueAnon = $anon;
}
} catch (Exception $e) {
$this->logger->error($e->getMessage());
@@ -696,19 +696,19 @@ readonly class TopicManager implements TopicManagerInterface
private function getUserCollection(PlayedGame $playedGame): array
{
$redUser = $playedGame->getRed();
$blueUser = $playedGame->getBlue();
$redUser = $playedGame->red;
$blueUser = $playedGame->blue;
return [
'red' => null !== $redUser ? $redUser->getUsername() : '',
'blue' => null !== $blueUser ? $blueUser->getUsername() : '',
'redAnon' => null !== $playedGame->getRedAnon() ? $playedGame->getRedAnon()->getUserName() : '',
'blueAnon' => null !== $playedGame->getBlueAnon() ? $playedGame->getBlueAnon()->getUserName() : '',
'redAvatar' => null !== $redUser && null !== $redUser->getAvatarPath()
? $this->cacheManager->generateUrl($redUser->getAvatarPath(), 'avatar_thumb')
'redAnon' => null !== $playedGame->redAnon ? $playedGame->redAnon->userName : '',
'blueAnon' => null !== $playedGame->blueAnon ? $playedGame->blueAnon->userName : '',
'redAvatar' => null !== $redUser && null !== $redUser->avatarPath
? $this->cacheManager->generateUrl($redUser->avatarPath, 'avatar_thumb')
: null,
'blueAvatar' => null !== $blueUser && null !== $blueUser->getAvatarPath()
? $this->cacheManager->generateUrl($blueUser->getAvatarPath(), 'avatar_thumb')
'blueAvatar' => null !== $blueUser && null !== $blueUser->avatarPath
? $this->cacheManager->generateUrl($blueUser->avatarPath, 'avatar_thumb')
: null,
];
}