示例#1
0
 /**
  * @return Sample
  */
 private function getComponent()
 {
     if (!$this->component) {
         $this->component = $this->componentFactory->create();
     }
     return $this->component;
 }
 /**
  * {@inheritdoc}
  */
 public function delete($id)
 {
     /** @var $sample \Magento\Downloadable\Model\Sample */
     $sample = $this->sampleFactory->create()->load($id);
     if (!$sample->getId()) {
         throw new NoSuchEntityException(__('There is no downloadable sample with provided ID.'));
     }
     try {
         $sample->delete();
     } catch (\Exception $exception) {
         throw new StateException(__('Cannot delete sample with id %1', $sample->getId()), $exception);
     }
     return true;
 }
示例#3
0
文件: Type.php 项目: nja78/magento2
 /**
  * @return \Magento\Downloadable\Model\Sample
  */
 protected function _createSample()
 {
     return $this->_sampleFactory->create();
 }
示例#4
0
 /**
  * @return ComponentInterface
  */
 protected function createItem()
 {
     return $this->sampleFactory->create();
 }