From 31e3097da36f630ed8eca70374f08d9c291493a8 Mon Sep 17 00:00:00 2001 From: Lang Date: Tue, 1 Nov 2016 13:20:14 +0100 Subject: [PATCH] refactor --- src/Mine/SeekerBundle/Rpc/MineseekerRpc.php | 22 +++++++++---------- .../SeekerBundle/Topic/MineseekerTopic.php | 9 ++++---- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/Mine/SeekerBundle/Rpc/MineseekerRpc.php b/src/Mine/SeekerBundle/Rpc/MineseekerRpc.php index 71d2104..e7ba0c0 100644 --- a/src/Mine/SeekerBundle/Rpc/MineseekerRpc.php +++ b/src/Mine/SeekerBundle/Rpc/MineseekerRpc.php @@ -13,10 +13,8 @@ use Gos\Bundle\WebSocketBundle\Router\WampRequest; class MineseekerRpc implements RpcInterface { - /** - * @var EntityManager - */ - protected $entityManager; + /** @var EntityManager */ + protected $em; protected $grid; @@ -26,7 +24,7 @@ class MineseekerRpc implements RpcInterface */ public function __construct(EntityManager $entityManager) { - $this->entityManager = $entityManager; + $this->em = $entityManager; } /** @@ -69,9 +67,9 @@ class MineseekerRpc implements RpcInterface { $getsee = array(); - $this->entityManager->clear(); + $this->em->clear(); - $grid = $this->entityManager + $grid = $this->em ->getRepository('MineSeekerBundle:PlayedGame') ->findOneByGameAssoc($gameAssoc) ->getGrid(); @@ -108,24 +106,24 @@ class MineseekerRpc implements RpcInterface /** Save Col */ $gridCol->setGridCol($gridRow); - $this->entityManager->persist($gridCol); + $this->em->persist($gridCol); } /** Save Row */ $gridRow->setGrid($grid); - $this->entityManager->persist($gridRow); + $this->em->persist($gridRow); } /** Save Grid */ $grid->setPlayedGame($playedGame); - $this->entityManager->persist($grid); + $this->em->persist($grid); /** Save PlayedGame */ $playedGame->setGameAssoc($data[1]); $playedGame->setGrid($grid); - $this->entityManager->persist($playedGame); + $this->em->persist($playedGame); - $this->entityManager->flush(); + $this->em->flush(); return true; } diff --git a/src/Mine/SeekerBundle/Topic/MineseekerTopic.php b/src/Mine/SeekerBundle/Topic/MineseekerTopic.php index 93d3298..68a3e96 100644 --- a/src/Mine/SeekerBundle/Topic/MineseekerTopic.php +++ b/src/Mine/SeekerBundle/Topic/MineseekerTopic.php @@ -6,7 +6,6 @@ use Doctrine\ORM\EntityManager; use Gos\Bundle\WebSocketBundle\Client\ClientManipulatorInterface; use Gos\Bundle\WebSocketBundle\Topic\TopicInterface; use Gos\Bundle\WebSocketBundle\Router\WampRequest; -use Guzzle\Http\Message\Request; use Mine\SeekerBundle\Entity\Gamer; use Mine\SeekerBundle\Entity\Step; use Ratchet\ConnectionInterface; @@ -189,10 +188,10 @@ class MineseekerTopic implements TopicInterface $this->em->flush(); return array( - 'red' => $playedGame->getRed() !== null ? $playedGame->getRed()->getUsername() : '', - 'blue' => $playedGame->getBlue() !== null ? $playedGame->getBlue()->getUsername() : '', - 'redAnon' => $playedGame->getRedAnon() !== null ? $playedGame->getRedAnon()->getUserName() : '', - 'blueAnon' => $playedGame->getBlueAnon() !== null ? $playedGame->getBlueAnon()->getUserName() : '' + '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() : '' ); } }