From 55caeedeabb343d4feae9b06684fe3df9f60b3aa Mon Sep 17 00:00:00 2001 From: Dmitry Gavriloff Date: Sat, 21 Jan 2017 21:31:15 +0400 Subject: [PATCH] =?UTF-8?q?issue=20#237=20=D0=92=D1=8B=D0=BD=D0=B5=D1=81?= =?UTF-8?q?=20=D0=BE=D1=82=D0=B2=D0=B5=D1=82=20=D0=B2=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BB=D0=BB=D0=B5=D1=80=20(#238)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Kubikvest/Handler/Checkpoint.php | 26 ++++++++++---------------- web/app.php | 4 +++- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/Kubikvest/Handler/Checkpoint.php b/src/Kubikvest/Handler/Checkpoint.php index 782d288..53f916b 100644 --- a/src/Kubikvest/Handler/Checkpoint.php +++ b/src/Kubikvest/Handler/Checkpoint.php @@ -19,14 +19,8 @@ namespace Kubikvest\Handler; use Kubikvest\Resource; -use Kubikvest\Validator\AccuracyLessDistance; -use Kubikvest\Validator\PlayerAtRightPlace; -use Kubikvest\Validator\PlayerFinished; -use Kubikvest\Validator\PointIncludedAccuracyRange; -use Kubikvest\Validator\PositionAroundBorderSector; -use Kubikvest\Validator\PositionInsideSector; +use Kubikvest\Validator; use Silex\Application; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Kubikvest\Model; @@ -45,7 +39,7 @@ public function __construct(Application $app) /** * @param Request $request * - * @return JsonResponse + * @return Resource\Respondent */ public function handle(Request $request) { @@ -71,17 +65,17 @@ public function handle(Request $request) $response->setPoint($point); $response->setQuest($quest); - $validator = new PlayerAtRightPlace( - new PositionInsideSector($position, $point->getSector()), - new PointIncludedAccuracyRange($position), - new AccuracyLessDistance($position, $point->getSector()), - new PositionAroundBorderSector($position, $point->getSector()) + $validator = new Validator\PlayerAtRightPlace( + new Validator\PositionInsideSector($position, $point->getSector()), + new Validator\PointIncludedAccuracyRange($position), + new Validator\AccuracyLessDistance($position, $point->getSector()), + new Validator\PositionAroundBorderSector($position, $point->getSector()) ); if (!$validator->validate()) { $response->error = 'Не верное место отметки.'; $response->addLink(Model\LinkGenerator::CHECKPOINT); - return (new Resource\Checkpoint\Respondent($response))->response(); + return new Resource\Checkpoint\Respondent($response); } /** @@ -89,7 +83,7 @@ public function handle(Request $request) */ $groupUpdater = $this->app[Resource\Group\Updater::class]; - if ((new PlayerFinished($group, $quest))->validate()) { + if ((new Validator\PlayerFinished($group, $quest))->validate()) { $group->active = false; $groupUpdater->update($group); $response->finish = true; @@ -108,6 +102,6 @@ public function handle(Request $request) ] ); - return (new Resource\Checkpoint\Respondent($response))->response(); + return new Resource\Checkpoint\Respondent($response); } } diff --git a/web/app.php b/web/app.php index 9156bb0..fbf8552 100644 --- a/web/app.php +++ b/web/app.php @@ -49,7 +49,9 @@ ] ); - return (new \Kubikvest\Handler\Checkpoint($app))->handle($request); + $respondent = (new \Kubikvest\Handler\Checkpoint($app))->handle($request); + + return $respondent->response(); }); $app->get('/finish', function (Request $request) use ($app) {