Пример #1
0
 /**
  * @param ComponentInterface $model
  * @param array $files
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function setFiles(ComponentInterface $model, array $files)
 {
     if ($model->getSampleType() == \Magento\Downloadable\Helper\Download::LINK_TYPE_FILE) {
         $fileName = $this->downloadableFile->moveFileFromTmp($model->getBaseTmpPath(), $model->getBasePath(), $files);
         $model->setSampleFile($fileName);
     }
     return $this;
 }
Пример #2
0
 /**
  * @param ComponentInterface $model
  * @param array $files
  * @return void
  */
 protected function setFiles(ComponentInterface $model, array $files)
 {
     $sampleFile = [];
     if ($this->sampleItem && isset($this->sampleItem['type'])) {
         if ($this->sampleItem['type'] == 'url' && $this->sampleItem['url'] != '') {
             $model->setSampleUrl($this->sampleItem['url']);
         }
         $model->setSampleType($this->sampleItem['type']);
         if (isset($this->sampleItem['file']) && $this->sampleItem['file']) {
             $sampleFile = $this->jsonHelper->jsonDecode($this->sampleItem['file']);
         }
     }
     if ($model->getLinkType() == \Magento\Downloadable\Helper\Download::LINK_TYPE_FILE) {
         $linkFileName = $this->downloadableFile->moveFileFromTmp($this->createItem()->getBaseTmpPath(), $this->createItem()->getBasePath(), $files);
         $model->setLinkFile($linkFileName);
     }
     if ($model->getSampleType() == \Magento\Downloadable\Helper\Download::LINK_TYPE_FILE) {
         $linkSampleFileName = $this->downloadableFile->moveFileFromTmp($this->createItem()->getBaseSampleTmpPath(), $this->createItem()->getBaseSamplePath(), $sampleFile);
         $model->setSampleFile($linkSampleFileName);
     }
 }