Пример #1
0
 public function it_can_handle_exception_during_request(RequestInterface $request)
 {
     $uuid = Uuid::uuid4();
     $request->offsetGet('uuid')->willReturn($uuid->toString());
     $request->getAcceptContentType()->willReturn('text/xml');
     $this->pageRepository->getByUuid($uuid)->willThrow(new \RuntimeException());
     $this->shouldThrow(ResponseException::class)->duringExecuteRequest($request);
 }
Пример #2
0
 public function executeRequest(RequestInterface $request) : ResponseInterface
 {
     try {
         $page = $this->pageRepository->getByUuid(Uuid::fromString($request['id']));
         $this->applyRequestToPage($request['attributes'], $page);
         $this->pageRepository->update($page);
         return new Response(self::MESSAGE, ['data' => $page], $request);
     } catch (\Throwable $exception) {
         $this->log(LogLevel::ERROR, $exception->getMessage());
         throw new ResponseException('An error occurred during UpdatePageHandler.', new ServerErrorResponse([], $request));
     }
 }
Пример #3
0
 public function executeRequest(RequestInterface $request) : ResponseInterface
 {
     try {
         $page = $this->pageRepository->getByUuid(Uuid::fromString($request['uuid']));
         return new Response(self::MESSAGE, ['data' => $page, 'includes' => ['pageBlocks']], $request);
     } catch (NoUniqueResultException $e) {
         return new NotFoundResponse([], $request);
     } catch (\Throwable $e) {
         $this->log(LogLevel::ERROR, $e->getMessage());
         throw new ResponseException('An error occurred during GetPageHandler.', new ServerErrorResponse([], $request));
     }
 }
Пример #4
0
 public function executeRequest(RequestInterface $request) : ResponseInterface
 {
     try {
         $page = $this->pageRepository->getByUuid(Uuid::fromString($request['id']));
         $pageBlock = $this->createBlockFromRequest($request, $page);
         $this->pageRepository->addBlockToPage($pageBlock, $page);
         return new Response(self::MESSAGE, ['data' => $pageBlock, 'includes' => ['pages']], $request);
     } catch (NoResultException $exception) {
         return new NotFoundResponse([], $request);
     } catch (\Throwable $exception) {
         $this->log(LogLevel::ERROR, $exception->getMessage());
         throw new ResponseException('An error occurred during AddPageBlockHandler.', new ServerErrorResponse([], $request));
     }
 }