diff --git a/src/Mine/SeekerBundle/Controller/GameController.php b/src/Mine/SeekerBundle/Controller/GameController.php index 65b6d91..ea125cb 100644 --- a/src/Mine/SeekerBundle/Controller/GameController.php +++ b/src/Mine/SeekerBundle/Controller/GameController.php @@ -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 + */ class GameController extends Controller { public function indexAction(Request $request) diff --git a/src/Mine/SeekerBundle/Entity/Gamer.php b/src/Mine/SeekerBundle/Entity/Gamer.php index 720249e..4856adf 100644 --- a/src/Mine/SeekerBundle/Entity/Gamer.php +++ b/src/Mine/SeekerBundle/Entity/Gamer.php @@ -5,7 +5,10 @@ namespace Mine\SeekerBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** - * Gamer + * Class Gamer + * + * @package Mine\SeekerBundle\Entity + * @author system7 * * @ORM\Table(name="gamer") * @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\GamerRepository") diff --git a/src/Mine/SeekerBundle/Entity/Grid.php b/src/Mine/SeekerBundle/Entity/Grid.php index f731f53..ad3be05 100644 --- a/src/Mine/SeekerBundle/Entity/Grid.php +++ b/src/Mine/SeekerBundle/Entity/Grid.php @@ -7,7 +7,10 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** - * Grid + * Class Grid + * + * @package Mine\SeekerBundle\Entity + * @author system7 * * @ORM\Table(name="grid") * @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\GridRepository") diff --git a/src/Mine/SeekerBundle/Entity/GridRow.php b/src/Mine/SeekerBundle/Entity/GridRow.php index cd2769d..7f3a7bb 100644 --- a/src/Mine/SeekerBundle/Entity/GridRow.php +++ b/src/Mine/SeekerBundle/Entity/GridRow.php @@ -5,7 +5,10 @@ namespace Mine\SeekerBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** - * GridRow + * Class GridRow + * + * @package Mine\SeekerBundle\Entity + * @author system7 * * @ORM\Table(name="grid_row") * @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\GridRowRepository") diff --git a/src/Mine/SeekerBundle/Entity/PlayedGame.php b/src/Mine/SeekerBundle/Entity/PlayedGame.php index 0aac095..d92f37d 100644 --- a/src/Mine/SeekerBundle/Entity/PlayedGame.php +++ b/src/Mine/SeekerBundle/Entity/PlayedGame.php @@ -8,7 +8,10 @@ use Doctrine\ORM\Mapping as ORM; use Jotunheimr\UserBundle\Entity\User; /** - * PlayedGame + * Class PlayedGame + * + * @package Mine\SeekerBundle\Entity + * @author system7 * * @ORM\Table(name="played_game") * @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\PlayedGameRepository") diff --git a/src/Mine/SeekerBundle/Entity/Step.php b/src/Mine/SeekerBundle/Entity/Step.php index 4f82cf6..bd4b7e2 100644 --- a/src/Mine/SeekerBundle/Entity/Step.php +++ b/src/Mine/SeekerBundle/Entity/Step.php @@ -5,7 +5,10 @@ namespace Mine\SeekerBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** - * Step + * Class Step + * + * @package Mine\SeekerBundle\Entity + * @author system7 * * @ORM\Table(name="step") * @ORM\Entity(repositoryClass="Mine\SeekerBundle\Repository\StepRepository") diff --git a/src/Mine/SeekerBundle/EventListener/MineseekerClientEventListener.php b/src/Mine/SeekerBundle/EventListener/MineseekerClientEventListener.php index 4f74ab2..ca17ec2 100644 --- a/src/Mine/SeekerBundle/EventListener/MineseekerClientEventListener.php +++ b/src/Mine/SeekerBundle/EventListener/MineseekerClientEventListener.php @@ -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 + */ class MineseekerClientEventListener { /** @@ -69,4 +75,4 @@ class MineseekerClientEventListener echo 'connection rejected from ' . $origin . PHP_EOL; } -} \ No newline at end of file +} diff --git a/src/Mine/SeekerBundle/Periodic/MinePeriodic.php b/src/Mine/SeekerBundle/Periodic/MinePeriodic.php index 1736b15..9c39ea4 100644 --- a/src/Mine/SeekerBundle/Periodic/MinePeriodic.php +++ b/src/Mine/SeekerBundle/Periodic/MinePeriodic.php @@ -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 + */ 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() { diff --git a/src/Mine/SeekerBundle/Repository/GamerRepository.php b/src/Mine/SeekerBundle/Repository/GamerRepository.php index 33d3fff..69dc8cd 100644 --- a/src/Mine/SeekerBundle/Repository/GamerRepository.php +++ b/src/Mine/SeekerBundle/Repository/GamerRepository.php @@ -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 */ class GamerRepository extends \Doctrine\ORM\EntityRepository { diff --git a/src/Mine/SeekerBundle/Repository/GridColRepository.php b/src/Mine/SeekerBundle/Repository/GridColRepository.php index a529c8c..06b92a2 100644 --- a/src/Mine/SeekerBundle/Repository/GridColRepository.php +++ b/src/Mine/SeekerBundle/Repository/GridColRepository.php @@ -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 */ class GridColRepository extends \Doctrine\ORM\EntityRepository { diff --git a/src/Mine/SeekerBundle/Repository/GridRepository.php b/src/Mine/SeekerBundle/Repository/GridRepository.php index 26a22c0..0e41128 100644 --- a/src/Mine/SeekerBundle/Repository/GridRepository.php +++ b/src/Mine/SeekerBundle/Repository/GridRepository.php @@ -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 */ class GridRepository extends \Doctrine\ORM\EntityRepository { diff --git a/src/Mine/SeekerBundle/Repository/GridRowRepository.php b/src/Mine/SeekerBundle/Repository/GridRowRepository.php index aecadfb..e7d40f9 100644 --- a/src/Mine/SeekerBundle/Repository/GridRowRepository.php +++ b/src/Mine/SeekerBundle/Repository/GridRowRepository.php @@ -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 */ class GridRowRepository extends EntityRepository { diff --git a/src/Mine/SeekerBundle/Repository/PlayedGameRepository.php b/src/Mine/SeekerBundle/Repository/PlayedGameRepository.php index b45488a..13df76e 100644 --- a/src/Mine/SeekerBundle/Repository/PlayedGameRepository.php +++ b/src/Mine/SeekerBundle/Repository/PlayedGameRepository.php @@ -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 */ class PlayedGameRepository extends \Doctrine\ORM\EntityRepository { diff --git a/src/Mine/SeekerBundle/Repository/StepRepository.php b/src/Mine/SeekerBundle/Repository/StepRepository.php index a57c587..d37ac85 100644 --- a/src/Mine/SeekerBundle/Repository/StepRepository.php +++ b/src/Mine/SeekerBundle/Repository/StepRepository.php @@ -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 */ class StepRepository extends \Doctrine\ORM\EntityRepository { diff --git a/src/Mine/SeekerBundle/Resources/translations/messages.en.yml b/src/Mine/SeekerBundle/Resources/translations/messages.en.yml index 8b13789..e69de29 100644 --- a/src/Mine/SeekerBundle/Resources/translations/messages.en.yml +++ b/src/Mine/SeekerBundle/Resources/translations/messages.en.yml @@ -1 +0,0 @@ - diff --git a/src/Mine/SeekerBundle/Rpc/MineseekerRpc.php b/src/Mine/SeekerBundle/Rpc/MineseekerRpc.php index 6553620..6ded139 100644 --- a/src/Mine/SeekerBundle/Rpc/MineseekerRpc.php +++ b/src/Mine/SeekerBundle/Rpc/MineseekerRpc.php @@ -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 + */ 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(); } } } diff --git a/src/Mine/SeekerBundle/Topic/MineseekerTopic.php b/src/Mine/SeekerBundle/Topic/MineseekerTopic.php index 1c57aae..6ca7e37 100644 --- a/src/Mine/SeekerBundle/Topic/MineseekerTopic.php +++ b/src/Mine/SeekerBundle/Topic/MineseekerTopic.php @@ -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 + */ 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(); } } } diff --git a/src/Mine/SeekerBundle/Topic/UserListTopic.php b/src/Mine/SeekerBundle/Topic/UserListTopic.php index 31c2506..a0c95c9 100644 --- a/src/Mine/SeekerBundle/Topic/UserListTopic.php +++ b/src/Mine/SeekerBundle/Topic/UserListTopic.php @@ -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 + */ 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(); } } }