public function __construct(UuidInterface $pageUuid, string $title, string $slug, string $shortTitle = null, UuidInterface $parentUuid = null, int $sortOrder = 0, PageStatusValue $status = null) { $this->pageUuid = $pageUuid; $this->setTitle($title); $this->setSlug($slug); $this->setShortTitle($shortTitle ?: $title); $this->parentUuid = $parentUuid; $this->sortOrder = $sortOrder; $this->status = $status ?: PageStatusValue::get(PageStatusValue::CONCEPT); }
public function __construct(UuidInterface $pageBlockUuid, Page $page, string $type, array $parameters, string $location, int $sortOrder, PageStatusValue $status = null) { $this->pageBlockUuid = $pageBlockUuid; $this->page = $page; $this->type = $type; $this->parameters = $parameters; $this->location = $location; $this->sortOrder = $sortOrder; $this->status = $status ?: PageStatusValue::get(PageStatusValue::CONCEPT); }
private function createBlockFromRequest(RequestInterface $request, Page $page) : PageBlock { $requestAttributes = $request['attributes']; $blockType = $this->blockTypeContainer->getType($requestAttributes['type']); $pageBlock = $blockType->newBlock($page, $requestAttributes['location'], $requestAttributes['sort_order'], PageStatusValue::get($requestAttributes['status'])); foreach ($requestAttributes['parameters'] as $parameter => $value) { $pageBlock[$parameter] = $value; } $blockType->validate($pageBlock, $request); return $pageBlock; }
/** {@inheritdoc} */ public function executeRequest(RequestInterface $request) : ResponseInterface { try { $page = new Page(Uuid::uuid4(), $request['title'], $request['slug'], $request['short_title'], $request['parent_uuid'] ? Uuid::fromString($request['parent_uuid']) : null, $request['sort_order'], PageStatusValue::get($request['status'])); $this->pageRepository->create($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 CreatePageHandler.', new ServerErrorResponse([], $request)); } }
public function it_can_execute_a_request_part_deux(RequestInterface $request, Page $page) { $pageUuid = Uuid::uuid4(); $attributes = ['sort_order' => $sortOrder = 3, 'status' => PageStatusValue::CONCEPT]; $request->offsetGet('id')->willReturn($pageUuid->toString()); $request->offsetGet('attributes')->willReturn($attributes); $request->getAcceptContentType()->willReturn('text/xml'); $this->pageRepository->getByUuid($pageUuid)->willReturn($page); $page->setSortOrder($sortOrder)->shouldBeCalled(); $page->setStatus(PageStatusValue::get($attributes['status']))->shouldBeCalled(); $this->pageRepository->update($page)->shouldBeCalled(); $response = $this->executeRequest($request); $response['data']->shouldBe($page); }
private function setPageStatus(Page $page, array $requestAttributes) { if (isset($requestAttributes['status'])) { $page->setStatus(PageStatusValue::get($requestAttributes['status'])); } }
public function it_can_delete_a_block_from_a_page(Page $page, PageBlock $block) { $uuid = Uuid::uuid4(); $page->getUuid()->willReturn($uuid); $page->removeBlock($block)->shouldBeCalled(); $page->metaDataSetUpdateTimestamp(new Argument\Token\TypeToken(\DateTimeImmutable::class))->shouldBeCalled(); $blockUuid = Uuid::uuid4(); $block->getUuid()->willReturn($blockUuid); $block->getPage()->willReturn($page); $block->setStatus(PageStatusValue::get('deleted'))->shouldBeCalled(); $this->objectRepository->delete(PageBlock::TYPE, $blockUuid)->shouldBeCalled(); $this->objectRepository->update(Page::TYPE, $uuid)->shouldBeCalled(); $this->deleteBlockFromPage($block, $page); }
private function getPageBlockFromRow(Page $page, array $row) : PageBlock { return (new PageBlock(Uuid::fromBytes($row['page_block_uuid']), $page, $row['type'], !is_null($row['parameters']) ? json_decode($row['parameters'], true) : [], $row['location'], intval($row['sort_order']), PageStatusValue::get($row['status'])))->metaDataSetInsertTimestamp(new \DateTimeImmutable($row['created']))->metaDataSetUpdateTimestamp(new \DateTimeImmutable($row['updated'])); }
public function let() { $this->page = (new Page(Uuid::uuid4(), 'Page Title', 'page_title', 'Title', Uuid::uuid4(), 42, PageStatusValue::get(PageStatusValue::PUBLISHED)))->metaDataSetInsertTimestamp(new \DateTimeImmutable())->metaDataSetUpdateTimestamp(new \DateTimeImmutable()); }
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); }
public function it_can_change_its_status() { $newStatus = PageStatusValue::get('published'); $this->setStatus($newStatus)->shouldReturn($this); $this->getStatus()->shouldReturn($newStatus); }
public function let(Page $page) { $this->block = (new PageBlock(Uuid::uuid4(), $page->getWrappedObject(), 'type', ['answer' => 42], 'main', 42, PageStatusValue::get(PageStatusValue::PUBLISHED)))->metaDataSetInsertTimestamp(new \DateTimeImmutable())->metaDataSetUpdateTimestamp(new \DateTimeImmutable()); }
private function setBlockStatus(PageBlock $block, RequestInterface $request) { if (isset($request['status'])) { $block->setStatus(PageStatusValue::get($request['status'])); } }