Private
Public Access
1
0

doc all entities

This commit is contained in:
2018-05-20 21:27:45 +02:00
parent 2f3062bf33
commit ae8794f564
18 changed files with 153 additions and 66 deletions

View File

@@ -2,12 +2,15 @@
namespace Mine\SeekerBundle\Controller;
//use CL\Slack\Payload\ChatPostMessagePayload;
//use CL\Slack\Payload\UsersListPayload;
//use CL\Slack\Transport\ApiClient;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
/**
* Class GameController
*
* @package Mine\SeekerBundle\Controller
* @author system7 <https://www.laszlolang.com>
*/
class GameController extends Controller
{
public function indexAction(Request $request)

View File

@@ -5,7 +5,10 @@ namespace Mine\SeekerBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Gamer
* Class Gamer
*
* @package Mine\SeekerBundle\Entity
* @author system7 <https://www.laszlolang.com>
*
* @ORM\Table(name="gamer")
* @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\GamerRepository")

View File

@@ -7,7 +7,10 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Grid
* Class Grid
*
* @package Mine\SeekerBundle\Entity
* @author system7 <https://www.laszlolang.com>
*
* @ORM\Table(name="grid")
* @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\GridRepository")

View File

@@ -5,7 +5,10 @@ namespace Mine\SeekerBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* GridRow
* Class GridRow
*
* @package Mine\SeekerBundle\Entity
* @author system7 <https://www.laszlolang.com>
*
* @ORM\Table(name="grid_row")
* @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\GridRowRepository")

View File

@@ -8,7 +8,10 @@ use Doctrine\ORM\Mapping as ORM;
use Jotunheimr\UserBundle\Entity\User;
/**
* PlayedGame
* Class PlayedGame
*
* @package Mine\SeekerBundle\Entity
* @author system7 <https://www.laszlolang.com>
*
* @ORM\Table(name="played_game")
* @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\PlayedGameRepository")

View File

@@ -5,7 +5,10 @@ namespace Mine\SeekerBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Step
* Class Step
*
* @package Mine\SeekerBundle\Entity
* @author system7 <https://www.laszlolang.com>
*
* @ORM\Table(name="step")
* @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\StepRepository")

View File

@@ -7,6 +7,12 @@ use Gos\Bundle\WebSocketBundle\Event\ClientErrorEvent;
use Gos\Bundle\WebSocketBundle\Event\ServerEvent;
use Gos\Bundle\WebSocketBundle\Event\ClientRejectedEvent;
/**
* Class MineseekerClientEventListener
*
* @package Mine\SeekerBundle\EventListener
* @author system7 <https://www.laszlolang.com>
*/
class MineseekerClientEventListener
{
/**

View File

@@ -4,8 +4,13 @@ namespace Mine\SeekerBundle\Periodic;
use Gos\Bundle\WebSocketBundle\Periodic\PdoPeriodicPing;
use Gos\Bundle\WebSocketBundle\Periodic\PeriodicInterface;
use PDO;
/**
* Class MinePeriodic
*
* @package Mine\SeekerBundle\Periodic
* @author system7 <https://www.laszlolang.com>
*/
class MinePeriodic implements PeriodicInterface
{
/** @var PdoPeriodicPing */
@@ -19,7 +24,8 @@ class MinePeriodic implements PeriodicInterface
/**
* This function is executed every 5 seconds.
*
* For more advanced functionality, try injecting a Topic Service to perform actions on your connections every x seconds.
* For more advanced functionality, try injecting a Topic Service to perform actions on your connections every x
* seconds.
*/
public function tick()
{

View File

@@ -3,10 +3,10 @@
namespace Mine\SeekerBundle\Repository;
/**
* GamerRepository
* Class GamerRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
* @package Mine\SeekerBundle\Repository
* @author system7 <https://www.laszlolang.com>
*/
class GamerRepository extends \Doctrine\ORM\EntityRepository
{

View File

@@ -3,10 +3,10 @@
namespace Mine\SeekerBundle\Repository;
/**
* GridColRepository
* Class GridColRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
* @package Mine\SeekerBundle\Repository
* @author system7 <https://www.laszlolang.com>
*/
class GridColRepository extends \Doctrine\ORM\EntityRepository
{

View File

@@ -3,10 +3,10 @@
namespace Mine\SeekerBundle\Repository;
/**
* GridRepository
* Class GridRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
* @package Mine\SeekerBundle\Repository
* @author system7 <https://www.laszlolang.com>
*/
class GridRepository extends \Doctrine\ORM\EntityRepository
{

View File

@@ -4,10 +4,10 @@ namespace Mine\SeekerBundle\Repository;
use Doctrine\ORM\EntityRepository;
/**
* GridRowRepository
* Class GridRowRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
* @package Mine\SeekerBundle\Repository
* @author system7 <https://www.laszlolang.com>
*/
class GridRowRepository extends EntityRepository
{

View File

@@ -3,10 +3,10 @@
namespace Mine\SeekerBundle\Repository;
/**
* PlayedGameRepository
* Class PlayedGameRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
* @package Mine\SeekerBundle\Repository
* @author system7 <https://www.laszlolang.com>
*/
class PlayedGameRepository extends \Doctrine\ORM\EntityRepository
{

View File

@@ -3,10 +3,10 @@
namespace Mine\SeekerBundle\Repository;
/**
* StepRepository
* Class StepRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
* @package Mine\SeekerBundle\Repository
* @author system7 <https://www.laszlolang.com>
*/
class StepRepository extends \Doctrine\ORM\EntityRepository
{

View File

@@ -4,13 +4,22 @@ namespace Mine\SeekerBundle\Rpc;
use Doctrine\DBAL\Driver\PDOException;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\OptimisticLockException;
use Mine\SeekerBundle\Entity\Grid;
use Mine\SeekerBundle\Entity\GridRow;
use Mine\SeekerBundle\Entity\PlayedGame;
use Ratchet\ConnectionInterface;
use Gos\Bundle\WebSocketBundle\RPC\RpcInterface;
use Gos\Bundle\WebSocketBundle\Router\WampRequest;
use Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class MineseekerRpc
*
* @package Mine\SeekerBundle\Rpc
* @author system7 <https://www.laszlolang.com>
*/
class MineseekerRpc implements RpcInterface
{
/** @var EntityManager */
@@ -18,6 +27,7 @@ class MineseekerRpc implements RpcInterface
/**
* MineseekerRpc constructor.
*
* @param EntityManager $entityManager
*/
public function __construct(EntityManager $entityManager)
@@ -37,9 +47,11 @@ class MineseekerRpc implements RpcInterface
/**
* @param ConnectionInterface $connection
* @param WampRequest $request
* @param array $params
* @param WampRequest $request
* @param array $params
*
* @return string Json string for frontend w/ numbering consideration. (=> a number is not string)
* @throws OptimisticLockException
*/
public function connectGame(ConnectionInterface $connection, WampRequest $request, array $params)
{
@@ -49,7 +61,9 @@ class MineseekerRpc implements RpcInterface
/**
* @param $data
*
* @return array|bool
* @throws OptimisticLockException
*/
private function getGrid($data)
{
@@ -57,11 +71,13 @@ class MineseekerRpc implements RpcInterface
$this->em->clear();
$grid = array();
/** @var PlayedGame $game */
$game = $this->em
->getRepository('MineSeekerBundle:PlayedGame')
->findOneByGameAssoc($data[1]);
if (null !== $game) {
/** @var GridRow $row */
foreach ($game->getGrid()->getGridRow()->toArray() as $row) {
$grid[] = $row->getGridCol();
}
@@ -75,7 +91,9 @@ class MineseekerRpc implements RpcInterface
/**
* @param $data
*
* @return boolean
* @throws OptimisticLockException
*/
private function saveGrid($data)
{
@@ -120,7 +138,7 @@ class MineseekerRpc implements RpcInterface
$connection->connect();
}
} catch (PDOException $ex) {
throw PDOException::class;
throw new NotFoundHttpException();
}
}
}

View File

@@ -4,15 +4,25 @@ namespace Mine\SeekerBundle\Topic;
use Doctrine\DBAL\Driver\PDOException;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\OptimisticLockException;
use Gos\Bundle\WebSocketBundle\Client\ClientManipulatorInterface;
use Gos\Bundle\WebSocketBundle\Topic\TopicInterface;
use Gos\Bundle\WebSocketBundle\Router\WampRequest;
use HWI\Bundle\OAuthBundle\Tests\Fixtures\FOSUser;
use Mine\SeekerBundle\Entity\Gamer;
use Mine\SeekerBundle\Entity\PlayedGame;
use Mine\SeekerBundle\Entity\Step;
use Ratchet\ConnectionInterface;
use Ratchet\Wamp\Topic;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class MineseekerTopic
*
* @package Mine\SeekerBundle\Topic
* @author system7 <https://www.laszlolang.com>
*/
class MineseekerTopic implements TopicInterface
{
/** @var ClientManipulatorInterface */
@@ -27,9 +37,9 @@ class MineseekerTopic implements TopicInterface
/**
* MineseekerTopic constructor.
*
* @param $clientManipulator ClientManipulatorInterface
* @param $clientManipulator ClientManipulatorInterface
* @param EntityManager $entityManager
* @param RequestStack $requestStack
* @param RequestStack $requestStack
*/
public function __construct(ClientManipulatorInterface $clientManipulator, EntityManager $entityManager, RequestStack $requestStack)
{
@@ -42,9 +52,11 @@ class MineseekerTopic implements TopicInterface
* This will receive any Subscription requests for this topic.
*
* @param ConnectionInterface $connection
* @param Topic $topic
* @param WampRequest $request
* @param Topic $topic
* @param WampRequest $request
*
* @return void
* @throws OptimisticLockException
*/
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
{
@@ -58,14 +70,14 @@ class MineseekerTopic implements TopicInterface
} else {
$users = $this->controlUsers($topic, $userName, $user);
$topic->broadcast([
$topic->broadcast(array(
'userTopicId' => $connection->resourceId,
'channel' => $topic->getId(),
'user' => $userName,
'userCnt' => $topic->count(),
'users' => $users,
'steps' => $this->getSteps($topic),
]);
));
}
}
@@ -73,8 +85,9 @@ class MineseekerTopic implements TopicInterface
* This will receive any UnSubscription requests for this topic.
*
* @param ConnectionInterface $connection
* @param Topic $topic
* @param WampRequest $request
* @param Topic $topic
* @param WampRequest $request
*
* @return void
*/
public function onUnSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
@@ -87,14 +100,16 @@ class MineseekerTopic implements TopicInterface
* This will receive any Publish requests for this topic.
*
* @param ConnectionInterface $connection
* @param Topic $topic
* @param WampRequest $request
* @param $event
* @param array $exclude
* @param array $eligible
* @param Topic $topic
* @param WampRequest $request
* @param $event
* @param array $exclude
* @param array $eligible
*
* @return mixed|void
* @internal param Topic $Topic
* @internal param array $eligibles
* @throws OptimisticLockException
*/
public function onPublish(ConnectionInterface $connection, Topic $topic, WampRequest $request, $event, array $exclude, array $eligible)
{
@@ -132,12 +147,15 @@ class MineseekerTopic implements TopicInterface
*
* @param $topic
* @param $color
*
* @throws OptimisticLockException
*/
private function saveResignToDb($topic, $color)
{
$this->reConnect();
$gameAssoc = explode('/', $topic->getId())[2];
/** @var PlayedGame $playedGame */
$playedGame = $this->em
->getRepository('MineSeekerBundle:PlayedGame')
->findOneByGameAssoc($gameAssoc);
@@ -150,14 +168,17 @@ class MineseekerTopic implements TopicInterface
/**
* Save steps and point information to database
*
* @param $topic
* @param $event
* @param Topic $topic
* @param $event
*
* @throws OptimisticLockException
*/
private function saveStepToDb($topic, $event)
{
$this->reConnect();
$gameAssoc = explode('/', $topic->getId())[2];
/** @var PlayedGame $playedGame */
$playedGame = $this->em
->getRepository('MineSeekerBundle:PlayedGame')
->findOneByGameAssoc($gameAssoc);
@@ -209,13 +230,16 @@ class MineseekerTopic implements TopicInterface
* @param $topic
* @param $userName
* @param $user
*
* @return array
* @throws OptimisticLockException
*/
private function controlUsers($topic, $userName, $user)
{
$this->reConnect();
$gameAssoc = explode('/', $topic->getId())[2];
/** @var PlayedGame $playedGame */
$playedGame = $this->em
->getRepository('MineSeekerBundle:PlayedGame')
->findOneByGameAssoc($gameAssoc);
@@ -240,11 +264,13 @@ class MineseekerTopic implements TopicInterface
/**
* Save user data to database
*
* @param $playedGame
* @param $userName
* @param $user
* @param $count
* @param PlayedGame $playedGame
* @param FOSUser $userName
* @param $user
* @param $count
*
* @return array
* @throws OptimisticLockException
*/
private function saveUserToDb($playedGame, $userName, $user, $count)
{
@@ -293,7 +319,8 @@ class MineseekerTopic implements TopicInterface
/**
* Get user collection from PlayedGame entity
*
* @param $playedGame
* @param PlayedGame $playedGame
*
* @return array
*/
private function getUserCollection($playedGame)
@@ -319,7 +346,7 @@ class MineseekerTopic implements TopicInterface
$connection->connect();
}
} catch (PDOException $ex) {
throw PDOException::class;
throw new NotFoundHttpException();
}
}
}

View File

@@ -10,7 +10,14 @@ use Gos\Bundle\WebSocketBundle\Router\WampRequest;
use Ratchet\ConnectionInterface;
use Ratchet\Wamp\Topic;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class UserListTopic
*
* @package Mine\SeekerBundle\Topic
* @author system7 <https://www.laszlolang.com>
*/
class UserListTopic implements TopicInterface
{
/** @var ClientManipulatorInterface */
@@ -25,9 +32,9 @@ class UserListTopic implements TopicInterface
/**
* MineseekerTopic constructor.
*
* @param $clientManipulator ClientManipulatorInterface
* @param $clientManipulator ClientManipulatorInterface
* @param EntityManager $entityManager
* @param RequestStack $requestStack
* @param RequestStack $requestStack
*/
public function __construct(ClientManipulatorInterface $clientManipulator, EntityManager $entityManager, RequestStack $requestStack)
{
@@ -40,8 +47,9 @@ class UserListTopic implements TopicInterface
* This will receive any Subscription requests for this topic.
*
* @param ConnectionInterface $connection
* @param Topic $topic
* @param WampRequest $request
* @param Topic $topic
* @param WampRequest $request
*
* @return void
*/
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
@@ -66,8 +74,9 @@ class UserListTopic implements TopicInterface
* This will receive any UnSubscription requests for this topic.
*
* @param ConnectionInterface $connection
* @param Topic $topic
* @param WampRequest $request
* @param Topic $topic
* @param WampRequest $request
*
* @return void
*/
public function onUnSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
@@ -80,11 +89,12 @@ class UserListTopic implements TopicInterface
* This will receive any Publish requests for this topic.
*
* @param ConnectionInterface $connection
* @param Topic $topic
* @param WampRequest $request
* @param $event
* @param array $exclude
* @param array $eligible
* @param Topic $topic
* @param WampRequest $request
* @param $event
* @param array $exclude
* @param array $eligible
*
* @return mixed|void
* @internal param Topic $Topic
* @internal param array $eligibles
@@ -146,6 +156,7 @@ class UserListTopic implements TopicInterface
/**
* @param $topic
* @param $username
*
* @return array
*/
private function findUser($topic, $username)
@@ -167,6 +178,7 @@ class UserListTopic implements TopicInterface
/**
* @param $topic
* @param $username
*
* @return array
*/
private function findUsersForSearch($topic, $username)
@@ -203,6 +215,7 @@ class UserListTopic implements TopicInterface
* Find all users online/offline
*
* @param $topic
*
* @return array
*/
private function findAllUsers($topic)
@@ -264,7 +277,7 @@ class UserListTopic implements TopicInterface
$connection->connect();
}
} catch (PDOException $ex) {
throw PDOException::class;
throw new NotFoundHttpException();
}
}
}