예제 #1
0
 public function executeRequest(RequestInterface $request) : ResponseInterface
 {
     try {
         $page = $this->pageRepository->getByUuid(Uuid::fromString($request['page_uuid']));
         $block = $page->getBlockByUuid(Uuid::fromString($request['uuid']));
         $this->applyRequestToBlock($request, $block);
         $this->pageRepository->updateBlockForPage($block, $page);
         return new Response(self::MESSAGE, ['data' => $block], $request);
     } catch (\Throwable $exception) {
         $this->log(LogLevel::ERROR, $exception->getMessage());
         throw new ResponseException('An error occurred during UpdatePageBlockHandler.', new ServerErrorResponse([], $request));
     }
 }
예제 #2
0
 public function it_can_execute_a_request_part_deux(RequestInterface $request, Page $page, PageBlock $pageBlock)
 {
     $pageUuid = Uuid::uuid4();
     $pageBlockUuid = Uuid::uuid4();
     $newStatus = PageStatusValue::get(PageStatusValue::DELETED);
     $request->offsetExists('page_uuid')->willReturn(true);
     $request->offsetGet('page_uuid')->willReturn($pageUuid->toString());
     $request->offsetExists('uuid')->willReturn(true);
     $request->offsetGet('uuid')->willReturn($pageBlockUuid->toString());
     $request->offsetExists('parameters')->willReturn(false);
     $request->offsetExists('sort_order')->willReturn(false);
     $request->offsetExists('status')->willReturn(true);
     $request->offsetGet('status')->willReturn($newStatus->toString());
     $request->getAcceptContentType()->willReturn('text/xml');
     $pageBlock->getType()->willReturn('type');
     $pageBlock->setStatus($newStatus)->shouldBeCalled();
     $this->pageRepository->getByUuid($pageUuid)->willReturn($page);
     $page->getBlockByUuid($pageBlockUuid)->willReturn($pageBlock);
     $pageBlock->getParameters()->willReturn(['content' => 'test']);
     $this->blockTypeContainer->getType('type')->willReturn(new HtmlContentBlockType());
     $this->pageRepository->updateBlockForPage($pageBlock, $page)->shouldBeCalled();
     $response = $this->executeRequest($request);
     $response['data']->shouldBe($pageBlock);
 }