slideManager = $teamService; } /** * @param ServerRequestInterface $request * @return ResponseInterface */ public function getList(ServerRequestInterface $request): ResponseInterface { return new JsonResponse($this->slideManager->listSlides()); } /** * @param ServerRequestInterface $request * @return ResponseInterface */ public function get(ServerRequestInterface $request): ResponseInterface { $id = $request->getAttribute('id'); return new JsonResponse($this->slideManager->getSlide((int)$id)); } /** * @param ServerRequestInterface $request * @return JsonResponse * @throws \Doctrine\ORM\ORMException * @throws \Doctrine\ORM\OptimisticLockException */ public function create(ServerRequestInterface $request) { $data = $this->getRequestData($request); try { return new JsonResponse($this->slideManager->addSlide($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 * @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->slideManager->changeSlide((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 * @throws \Doctrine\ORM\ORMException */ public function delete(ServerRequestInterface $request) { $id = $request->getAttribute('id'); return new JsonResponse($this->slideManager->removeSlide((int)$id)); } }