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; 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\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
/**
* Class GameController
*
* @package Mine\SeekerBundle\Controller
* @author system7 <https://www.laszlolang.com>
*/
class GameController extends Controller class GameController extends Controller
{ {
public function indexAction(Request $request) public function indexAction(Request $request)

View File

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

View File

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

View File

@@ -5,7 +5,10 @@ namespace Mine\SeekerBundle\Entity;
use Doctrine\ORM\Mapping as ORM; 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\Table(name="grid_row")
* @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\GridRowRepository") * @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\GridRowRepository")

View File

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

View File

@@ -5,7 +5,10 @@ namespace Mine\SeekerBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
* Step * Class Step
*
* @package Mine\SeekerBundle\Entity
* @author system7 <https://www.laszlolang.com>
* *
* @ORM\Table(name="step") * @ORM\Table(name="step")
* @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\StepRepository") * @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\ServerEvent;
use Gos\Bundle\WebSocketBundle\Event\ClientRejectedEvent; use Gos\Bundle\WebSocketBundle\Event\ClientRejectedEvent;
/**
* Class MineseekerClientEventListener
*
* @package Mine\SeekerBundle\EventListener
* @author system7 <https://www.laszlolang.com>
*/
class MineseekerClientEventListener class MineseekerClientEventListener
{ {
/** /**

View File

@@ -4,8 +4,13 @@ namespace Mine\SeekerBundle\Periodic;
use Gos\Bundle\WebSocketBundle\Periodic\PdoPeriodicPing; use Gos\Bundle\WebSocketBundle\Periodic\PdoPeriodicPing;
use Gos\Bundle\WebSocketBundle\Periodic\PeriodicInterface; use Gos\Bundle\WebSocketBundle\Periodic\PeriodicInterface;
use PDO;
/**
* Class MinePeriodic
*
* @package Mine\SeekerBundle\Periodic
* @author system7 <https://www.laszlolang.com>
*/
class MinePeriodic implements PeriodicInterface class MinePeriodic implements PeriodicInterface
{ {
/** @var PdoPeriodicPing */ /** @var PdoPeriodicPing */
@@ -19,7 +24,8 @@ class MinePeriodic implements PeriodicInterface
/** /**
* This function is executed every 5 seconds. * 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() public function tick()
{ {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,13 +4,22 @@ namespace Mine\SeekerBundle\Rpc;
use Doctrine\DBAL\Driver\PDOException; use Doctrine\DBAL\Driver\PDOException;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\OptimisticLockException;
use Mine\SeekerBundle\Entity\Grid; use Mine\SeekerBundle\Entity\Grid;
use Mine\SeekerBundle\Entity\GridRow; use Mine\SeekerBundle\Entity\GridRow;
use Mine\SeekerBundle\Entity\PlayedGame; use Mine\SeekerBundle\Entity\PlayedGame;
use Ratchet\ConnectionInterface; use Ratchet\ConnectionInterface;
use Gos\Bundle\WebSocketBundle\RPC\RpcInterface; use Gos\Bundle\WebSocketBundle\RPC\RpcInterface;
use Gos\Bundle\WebSocketBundle\Router\WampRequest; 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 class MineseekerRpc implements RpcInterface
{ {
/** @var EntityManager */ /** @var EntityManager */
@@ -18,6 +27,7 @@ class MineseekerRpc implements RpcInterface
/** /**
* MineseekerRpc constructor. * MineseekerRpc constructor.
*
* @param EntityManager $entityManager * @param EntityManager $entityManager
*/ */
public function __construct(EntityManager $entityManager) public function __construct(EntityManager $entityManager)
@@ -39,7 +49,9 @@ class MineseekerRpc implements RpcInterface
* @param ConnectionInterface $connection * @param ConnectionInterface $connection
* @param WampRequest $request * @param WampRequest $request
* @param array $params * @param array $params
*
* @return string Json string for frontend w/ numbering consideration. (=> a number is not string) * @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) public function connectGame(ConnectionInterface $connection, WampRequest $request, array $params)
{ {
@@ -49,7 +61,9 @@ class MineseekerRpc implements RpcInterface
/** /**
* @param $data * @param $data
*
* @return array|bool * @return array|bool
* @throws OptimisticLockException
*/ */
private function getGrid($data) private function getGrid($data)
{ {
@@ -57,11 +71,13 @@ class MineseekerRpc implements RpcInterface
$this->em->clear(); $this->em->clear();
$grid = array(); $grid = array();
/** @var PlayedGame $game */
$game = $this->em $game = $this->em
->getRepository('MineSeekerBundle:PlayedGame') ->getRepository('MineSeekerBundle:PlayedGame')
->findOneByGameAssoc($data[1]); ->findOneByGameAssoc($data[1]);
if (null !== $game) { if (null !== $game) {
/** @var GridRow $row */
foreach ($game->getGrid()->getGridRow()->toArray() as $row) { foreach ($game->getGrid()->getGridRow()->toArray() as $row) {
$grid[] = $row->getGridCol(); $grid[] = $row->getGridCol();
} }
@@ -75,7 +91,9 @@ class MineseekerRpc implements RpcInterface
/** /**
* @param $data * @param $data
*
* @return boolean * @return boolean
* @throws OptimisticLockException
*/ */
private function saveGrid($data) private function saveGrid($data)
{ {
@@ -120,7 +138,7 @@ class MineseekerRpc implements RpcInterface
$connection->connect(); $connection->connect();
} }
} catch (PDOException $ex) { } 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\DBAL\Driver\PDOException;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\OptimisticLockException;
use Gos\Bundle\WebSocketBundle\Client\ClientManipulatorInterface; use Gos\Bundle\WebSocketBundle\Client\ClientManipulatorInterface;
use Gos\Bundle\WebSocketBundle\Topic\TopicInterface; use Gos\Bundle\WebSocketBundle\Topic\TopicInterface;
use Gos\Bundle\WebSocketBundle\Router\WampRequest; use Gos\Bundle\WebSocketBundle\Router\WampRequest;
use HWI\Bundle\OAuthBundle\Tests\Fixtures\FOSUser;
use Mine\SeekerBundle\Entity\Gamer; use Mine\SeekerBundle\Entity\Gamer;
use Mine\SeekerBundle\Entity\PlayedGame;
use Mine\SeekerBundle\Entity\Step; use Mine\SeekerBundle\Entity\Step;
use Ratchet\ConnectionInterface; use Ratchet\ConnectionInterface;
use Ratchet\Wamp\Topic; use Ratchet\Wamp\Topic;
use Symfony\Component\HttpFoundation\RequestStack; 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 class MineseekerTopic implements TopicInterface
{ {
/** @var ClientManipulatorInterface */ /** @var ClientManipulatorInterface */
@@ -44,7 +54,9 @@ class MineseekerTopic implements TopicInterface
* @param ConnectionInterface $connection * @param ConnectionInterface $connection
* @param Topic $topic * @param Topic $topic
* @param WampRequest $request * @param WampRequest $request
*
* @return void * @return void
* @throws OptimisticLockException
*/ */
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request) public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
{ {
@@ -58,14 +70,14 @@ class MineseekerTopic implements TopicInterface
} else { } else {
$users = $this->controlUsers($topic, $userName, $user); $users = $this->controlUsers($topic, $userName, $user);
$topic->broadcast([ $topic->broadcast(array(
'userTopicId' => $connection->resourceId, 'userTopicId' => $connection->resourceId,
'channel' => $topic->getId(), 'channel' => $topic->getId(),
'user' => $userName, 'user' => $userName,
'userCnt' => $topic->count(), 'userCnt' => $topic->count(),
'users' => $users, 'users' => $users,
'steps' => $this->getSteps($topic), 'steps' => $this->getSteps($topic),
]); ));
} }
} }
@@ -75,6 +87,7 @@ class MineseekerTopic implements TopicInterface
* @param ConnectionInterface $connection * @param ConnectionInterface $connection
* @param Topic $topic * @param Topic $topic
* @param WampRequest $request * @param WampRequest $request
*
* @return void * @return void
*/ */
public function onUnSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request) public function onUnSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
@@ -92,9 +105,11 @@ class MineseekerTopic implements TopicInterface
* @param $event * @param $event
* @param array $exclude * @param array $exclude
* @param array $eligible * @param array $eligible
*
* @return mixed|void * @return mixed|void
* @internal param Topic $Topic * @internal param Topic $Topic
* @internal param array $eligibles * @internal param array $eligibles
* @throws OptimisticLockException
*/ */
public function onPublish(ConnectionInterface $connection, Topic $topic, WampRequest $request, $event, array $exclude, array $eligible) 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 $topic
* @param $color * @param $color
*
* @throws OptimisticLockException
*/ */
private function saveResignToDb($topic, $color) private function saveResignToDb($topic, $color)
{ {
$this->reConnect(); $this->reConnect();
$gameAssoc = explode('/', $topic->getId())[2]; $gameAssoc = explode('/', $topic->getId())[2];
/** @var PlayedGame $playedGame */
$playedGame = $this->em $playedGame = $this->em
->getRepository('MineSeekerBundle:PlayedGame') ->getRepository('MineSeekerBundle:PlayedGame')
->findOneByGameAssoc($gameAssoc); ->findOneByGameAssoc($gameAssoc);
@@ -150,14 +168,17 @@ class MineseekerTopic implements TopicInterface
/** /**
* Save steps and point information to database * Save steps and point information to database
* *
* @param $topic * @param Topic $topic
* @param $event * @param $event
*
* @throws OptimisticLockException
*/ */
private function saveStepToDb($topic, $event) private function saveStepToDb($topic, $event)
{ {
$this->reConnect(); $this->reConnect();
$gameAssoc = explode('/', $topic->getId())[2]; $gameAssoc = explode('/', $topic->getId())[2];
/** @var PlayedGame $playedGame */
$playedGame = $this->em $playedGame = $this->em
->getRepository('MineSeekerBundle:PlayedGame') ->getRepository('MineSeekerBundle:PlayedGame')
->findOneByGameAssoc($gameAssoc); ->findOneByGameAssoc($gameAssoc);
@@ -209,13 +230,16 @@ class MineseekerTopic implements TopicInterface
* @param $topic * @param $topic
* @param $userName * @param $userName
* @param $user * @param $user
*
* @return array * @return array
* @throws OptimisticLockException
*/ */
private function controlUsers($topic, $userName, $user) private function controlUsers($topic, $userName, $user)
{ {
$this->reConnect(); $this->reConnect();
$gameAssoc = explode('/', $topic->getId())[2]; $gameAssoc = explode('/', $topic->getId())[2];
/** @var PlayedGame $playedGame */
$playedGame = $this->em $playedGame = $this->em
->getRepository('MineSeekerBundle:PlayedGame') ->getRepository('MineSeekerBundle:PlayedGame')
->findOneByGameAssoc($gameAssoc); ->findOneByGameAssoc($gameAssoc);
@@ -240,11 +264,13 @@ class MineseekerTopic implements TopicInterface
/** /**
* Save user data to database * Save user data to database
* *
* @param $playedGame * @param PlayedGame $playedGame
* @param $userName * @param FOSUser $userName
* @param $user * @param $user
* @param $count * @param $count
*
* @return array * @return array
* @throws OptimisticLockException
*/ */
private function saveUserToDb($playedGame, $userName, $user, $count) private function saveUserToDb($playedGame, $userName, $user, $count)
{ {
@@ -293,7 +319,8 @@ class MineseekerTopic implements TopicInterface
/** /**
* Get user collection from PlayedGame entity * Get user collection from PlayedGame entity
* *
* @param $playedGame * @param PlayedGame $playedGame
*
* @return array * @return array
*/ */
private function getUserCollection($playedGame) private function getUserCollection($playedGame)
@@ -319,7 +346,7 @@ class MineseekerTopic implements TopicInterface
$connection->connect(); $connection->connect();
} }
} catch (PDOException $ex) { } 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\ConnectionInterface;
use Ratchet\Wamp\Topic; use Ratchet\Wamp\Topic;
use Symfony\Component\HttpFoundation\RequestStack; 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 class UserListTopic implements TopicInterface
{ {
/** @var ClientManipulatorInterface */ /** @var ClientManipulatorInterface */
@@ -42,6 +49,7 @@ class UserListTopic implements TopicInterface
* @param ConnectionInterface $connection * @param ConnectionInterface $connection
* @param Topic $topic * @param Topic $topic
* @param WampRequest $request * @param WampRequest $request
*
* @return void * @return void
*/ */
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request) public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
@@ -68,6 +76,7 @@ class UserListTopic implements TopicInterface
* @param ConnectionInterface $connection * @param ConnectionInterface $connection
* @param Topic $topic * @param Topic $topic
* @param WampRequest $request * @param WampRequest $request
*
* @return void * @return void
*/ */
public function onUnSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request) public function onUnSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
@@ -85,6 +94,7 @@ class UserListTopic implements TopicInterface
* @param $event * @param $event
* @param array $exclude * @param array $exclude
* @param array $eligible * @param array $eligible
*
* @return mixed|void * @return mixed|void
* @internal param Topic $Topic * @internal param Topic $Topic
* @internal param array $eligibles * @internal param array $eligibles
@@ -146,6 +156,7 @@ class UserListTopic implements TopicInterface
/** /**
* @param $topic * @param $topic
* @param $username * @param $username
*
* @return array * @return array
*/ */
private function findUser($topic, $username) private function findUser($topic, $username)
@@ -167,6 +178,7 @@ class UserListTopic implements TopicInterface
/** /**
* @param $topic * @param $topic
* @param $username * @param $username
*
* @return array * @return array
*/ */
private function findUsersForSearch($topic, $username) private function findUsersForSearch($topic, $username)
@@ -203,6 +215,7 @@ class UserListTopic implements TopicInterface
* Find all users online/offline * Find all users online/offline
* *
* @param $topic * @param $topic
*
* @return array * @return array
*/ */
private function findAllUsers($topic) private function findAllUsers($topic)
@@ -264,7 +277,7 @@ class UserListTopic implements TopicInterface
$connection->connect(); $connection->connect();
} }
} catch (PDOException $ex) { } catch (PDOException $ex) {
throw PDOException::class; throw new NotFoundHttpException();
} }
} }
} }