Private
Public Access
1
0

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:
2026-04-09 20:21:01 +02:00
parent 23547f4237
commit b55c223d8a
55 changed files with 1567 additions and 4398 deletions

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* This file is part of the SplendidBear Websites' projects.
*
@@ -10,11 +10,11 @@
namespace App\Util;
use App\Application\Sonata\UserBundle\Entity\User;
use App\Entity\User;
use App\Entity\Gamer;
use App\Entity\PlayedGame;
use App\Entity\Step;
use App\Util\Interfaces\TopicManagerInterface;
use App\Interfaces\TopicManagerInterface;
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
@@ -28,49 +28,25 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
/**
* Class TopicManager
*
* @package App\Util
* @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 TopicManager extends WebsocketManager implements TopicManagerInterface
{
/** @var ClientManipulatorInterface $clientManipulator */
protected $clientManipulator;
/** @var EntityManagerInterface $entityManager */
protected $entityManager;
/** @var RequestStack $requestStack */
protected $requestStack;
/** @var LoggerInterface $logger */
protected $logger;
/**
* TopicManager constructor.
*
* @param ClientManipulatorInterface $clientManipulator
* @param EntityManagerInterface $entityManager
* @param RequestStack $requestStack
* @param LoggerInterface $logger
*/
public function __construct(
ClientManipulatorInterface $clientManipulator,
EntityManagerInterface $entityManager,
RequestStack $requestStack,
LoggerInterface $logger
protected ClientManipulatorInterface $clientManipulator,
protected EntityManagerInterface $entityManager,
protected RequestStack $requestStack,
protected LoggerInterface $logger
)
{
$this->clientManipulator = $clientManipulator;
$this->entityManager = $this->reConnect($entityManager);
$this->requestStack = $requestStack;
$this->logger = $logger;
parent::__construct($logger);
}
/**
* {@inheritDoc}
*/
public function subscribe(Topic $topic, ConnectionInterface $connection): void
{
/** this will broadcast the message to ALL subscribers of this topic. */
@@ -93,18 +69,12 @@ class TopicManager extends WebsocketManager implements TopicManagerInterface
}
}
/**
* {@inheritDoc}
*/
public function unSubscribe(Topic $topic, ConnectionInterface $connection): void
{
/** This will broadcasts the message to ALL subscribers of this topic. */
$topic->broadcast(array('msg' => $connection->resourceId . ' has left ' . $topic->getId()));
$topic->broadcast(['msg' => $connection->resourceId . ' has left ' . $topic->getId()]);
}
/**
* {@inheritDoc}
*/
public function publish(Topic $topic, ConnectionInterface $connection, $event): void
{
$user = $this->clientManipulator->getClient($connection);
@@ -319,11 +289,11 @@ class TopicManager extends WebsocketManager implements TopicManagerInterface
*/
private function getUserCollection(PlayedGame $playedGame): array
{
return 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() : ''
);
];
}
}