Beispiel #1
0
 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);
 }
Beispiel #2
0
 public function deleteBlockFromPage(PageBlock $block, Page $page)
 {
     if (!$page->getUuid()->equals($block->getPage()->getUuid())) {
         throw new \OutOfBoundsException('PageBlock must belong to page to be added to it.');
     }
     // The database constraint should cascade the delete to the page
     $this->objectRepository->delete(PageBlock::TYPE, $block->getUuid());
     $page->removeBlock($block);
     $this->objectRepository->update(Page::TYPE, $page->getUuid());
     $page->metaDataSetUpdateTimestamp(new \DateTimeImmutable());
     $block->setStatus(PageStatusValue::get(PageStatusValue::DELETED));
 }