chg: pkg: make a massive refactor to the backend and remove all unnecessary deps - and make small refactors for the frontend too #4
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of the SplendidBear Websites' projects.
|
||||
*
|
||||
@@ -13,9 +13,8 @@ namespace App\Util;
|
||||
use App\Entity\Grid;
|
||||
use App\Entity\GridRow;
|
||||
use App\Entity\PlayedGame;
|
||||
use App\Util\Interfaces\RpcManagerInterface;
|
||||
use App\Interfaces\RpcManagerInterface;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\ORMException;
|
||||
use Exception;
|
||||
@@ -24,49 +23,34 @@ use Psr\Log\LoggerInterface;
|
||||
/**
|
||||
* Class RpcManager
|
||||
*
|
||||
* @package App\Utils
|
||||
* @author system7 <https://www.splendidbear.org>
|
||||
* @package App\Util
|
||||
* @author Lang <https://www.splendidbear.org>
|
||||
* @category Class
|
||||
* @license https://www.gnu.org/licenses/lgpl-3.0.en.html GNU Lesser General Public License
|
||||
* @link www.splendidbear.org
|
||||
* @since 2026. 04. 09.
|
||||
*/
|
||||
class RpcManager extends WebsocketManager implements RpcManagerInterface
|
||||
{
|
||||
/** @var EntityManager $em */
|
||||
protected $entityManager;
|
||||
|
||||
/** @var LoggerInterface $logger */
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* MineseekerRpc constructor.
|
||||
*
|
||||
* @param EntityManagerInterface $entityManager
|
||||
* @param LoggerInterface $logger
|
||||
*/
|
||||
public function __construct(EntityManagerInterface $entityManager, LoggerInterface $logger)
|
||||
{
|
||||
$this->entityManager = $this->reConnect($entityManager);
|
||||
$this->logger = $logger;
|
||||
|
||||
public function __construct(
|
||||
private EntityManagerInterface $entityManager,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getConnectInformation($params): string
|
||||
{
|
||||
$gameAssoc = is_array($params) ? $params[0] : $params;
|
||||
$grid = $this->getGrid($gameAssoc);
|
||||
$users = null !== $grid ? $this->getUsers($gameAssoc) : null;
|
||||
|
||||
return base64_encode(json_encode(array(
|
||||
'grid' => $grid,
|
||||
'users' => $users
|
||||
), JSON_THROW_ON_ERROR, 512));
|
||||
return base64_encode(json_encode([
|
||||
'grid' => $grid,
|
||||
'users' => $users,
|
||||
], JSON_THROW_ON_ERROR, 512));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function saveGrid($data): bool
|
||||
{
|
||||
$playedGame = new PlayedGame();
|
||||
@@ -173,11 +157,11 @@ class RpcManager extends WebsocketManager implements RpcManagerInterface
|
||||
*/
|
||||
private function getUserCollection(PlayedGame $playedGame): array
|
||||
{
|
||||
return array(
|
||||
'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() : ''
|
||||
);
|
||||
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() : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user