/**
  * Save Block data
  *
  * @param \Magento\Cms\Api\Data\BlockInterface $block
  * @return Block
  * @throws CouldNotSaveException
  */
 public function save(Data\BlockInterface $block)
 {
     $storeId = $this->storeManager->getStore()->getId();
     $block->setStoreId($storeId);
     try {
         $this->resource->save($block);
     } catch (\Exception $exception) {
         throw new CouldNotSaveException(__($exception->getMessage()));
     }
     return $block;
 }
 /**
  * Test delete \Magento\Cms\Api\Data\BlockInterface
  * @expectedException \Magento\Framework\Exception\NoSuchEntityException
  */
 public function testDelete()
 {
     $blockTitle = 'Block title';
     $blockIdentifier = 'block-title';
     /** @var  \Magento\Cms\Api\Data\BlockInterface $blockDataObject */
     $blockDataObject = $this->blockFactory->create();
     $blockDataObject->setTitle($blockTitle)->setIdentifier($blockIdentifier);
     $this->currentBlock = $this->blockRepository->save($blockDataObject);
     $serviceInfo = ['rest' => ['resourcePath' => self::RESOURCE_PATH . '/' . $this->currentBlock->getId(), 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_DELETE], 'soap' => ['service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, 'operation' => self::SERVICE_NAME . 'DeleteById']];
     $this->_webApiCall($serviceInfo, [BlockInterface::BLOCK_ID => $this->currentBlock->getId()]);
     $this->blockRepository->getById($this->currentBlock['id']);
 }
Example #3
0
 /**
  * Add block title to error message
  *
  * @param BlockInterface $block
  * @param string $errorText
  * @return string
  */
 protected function getErrorWithBlockId(BlockInterface $block, $errorText)
 {
     return '[Block ID: ' . $block->getId() . '] ' . $errorText;
 }