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) {