* changed routes while debuging endpoints

* added corsmiddlewarefactory
* changing teams is now possible
This commit is contained in:
Dávid Danyi
2018-04-09 18:41:04 +02:00
parent 1143075e17
commit 117c10a56a
5 changed files with 62 additions and 9 deletions

View File

@@ -60,6 +60,29 @@ class TeamHandler extends AbstractCrudHandler
}
}
/**
* @param ServerRequestInterface $request
* @return JsonResponse
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
*/
public function update(ServerRequestInterface $request)
{
$id = $request->getAttribute('id');
$data = $this->getRequestData($request);
try {
return new JsonResponse($this->teamService->changeTeam((int)$id, $data));
} catch (UniqueConstraintViolationException $e) {
return new JsonResponse([
'message' => 'The field `name` must be unique',
], 500);
} catch (\InvalidArgumentException $e) {
return new JsonResponse([
'message' => $e->getMessage(),
], 500);
}
}
/**
* @param ServerRequestInterface $request
* @return JsonResponse