当前位置: 首页>>代码示例>>PHP>>正文


PHP WriteInterface::copyFile方法代码示例

本文整理汇总了PHP中Magento\Framework\Filesystem\Directory\WriteInterface::copyFile方法的典型用法代码示例。如果您正苦于以下问题:PHP WriteInterface::copyFile方法的具体用法?PHP WriteInterface::copyFile怎么用?PHP WriteInterface::copyFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Filesystem\Directory\WriteInterface的用法示例。


在下文中一共展示了WriteInterface::copyFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _moveFile

 /**
  * Move files from TMP folder into destination folder
  *
  * @param string $tmpPath
  * @param string $destPath
  * @return bool
  */
 protected function _moveFile($tmpPath, $destPath)
 {
     if ($this->_directory->isFile($tmpPath)) {
         return $this->_directory->copyFile($tmpPath, $destPath);
     } else {
         return false;
     }
 }
开发者ID:nja78,项目名称:magento2,代码行数:15,代码来源:Uploader.php

示例2: duplicateImageFromTmp

 /**
  * Duplicate temporary images
  *
  * @param string $file
  * @return string
  */
 public function duplicateImageFromTmp($file)
 {
     $file = $this->getFilenameFromTmp($file);
     $destinationFile = $this->getUniqueFileName($file, true);
     if ($this->fileStorageDb->checkDbUsage()) {
         $this->fileStorageDb->copyFile($this->mediaDirectory->getAbsolutePath($this->mediaConfig->getTmpMediaShortUrl($file)), $this->mediaConfig->getTmpMediaShortUrl($destinationFile));
     } else {
         $this->mediaDirectory->copyFile($this->mediaConfig->getTmpMediaPath($file), $this->mediaConfig->getTmpMediaPath($destinationFile));
     }
     return str_replace('\\', '/', $destinationFile);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:AbstractMedia.php

示例3: _moveFile

 /**
  * Move files from TMP folder into destination folder
  *
  * @param string $tmpPath
  * @param string $destPath
  * @return bool
  */
 protected function _moveFile($tmpPath, $destPath)
 {
     if ($this->_directory->isFile($tmpPath)) {
         $tmpRealPath = $this->_directory->getDriver()->getRealPath($this->_directory->getAbsolutePath($tmpPath));
         $destinationRealPath = $this->_directory->getDriver()->getRealPath($this->_directory->getAbsolutePath($destPath));
         $isSameFile = $tmpRealPath === $destinationRealPath;
         return $isSameFile ?: $this->_directory->copyFile($tmpPath, $destPath);
     } else {
         return false;
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:Uploader.php

示例4: _copyImage

 /**
  * Copy image and return new filename.
  *
  * @param string $file
  * @return string
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _copyImage($file)
 {
     try {
         $destinationFile = $this->_getUniqueFileName($file);
         if (!$this->_mediaDirectory->isFile($this->_mediaConfig->getMediaPath($file))) {
             throw new \Exception();
         }
         if ($this->_fileStorageDb->checkDbUsage()) {
             $this->_fileStorageDb->copyFile($this->_mediaDirectory->getAbsolutePath($this->_mediaConfig->getMediaShortUrl($file)), $this->_mediaConfig->getMediaShortUrl($destinationFile));
             $this->_mediaDirectory->delete($this->_mediaConfig->getMediaPath($destinationFile));
         } else {
             $this->_mediaDirectory->copyFile($this->_mediaConfig->getMediaPath($file), $this->_mediaConfig->getMediaPath($destinationFile));
         }
         return str_replace('\\', '/', $destinationFile);
     } catch (\Exception $e) {
         $file = $this->_mediaConfig->getMediaPath($file);
         throw new LocalizedException(__('We couldn\'t copy file %1. Please delete media with non-existing images and try again.', $file));
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:26,代码来源:Media.php

示例5: createPreviewImageCopy

 /**
  * Create preview image duplicate
  *
  * @param ThemeInterface $theme
  * @return bool
  */
 public function createPreviewImageCopy(ThemeInterface $theme)
 {
     $previewDir = $this->themeImagePath->getImagePreviewDirectory();
     $sourcePath = $theme->getThemeImage()->getPreviewImagePath();
     $sourceRelativePath = $this->rootDirectory->getRelativePath($sourcePath);
     if (!$theme->getPreviewImage() && !$this->mediaDirectory->isExist($sourceRelativePath)) {
         return false;
     }
     $isCopied = false;
     try {
         $destinationFileName = \Magento\Framework\File\Uploader::getNewFileName($sourcePath);
         $targetRelativePath = $this->mediaDirectory->getRelativePath($previewDir . '/' . $destinationFileName);
         $isCopied = $this->rootDirectory->copyFile($sourceRelativePath, $targetRelativePath, $this->mediaDirectory);
         $this->theme->setPreviewImage($destinationFileName);
     } catch (\Magento\Framework\Filesystem\FilesystemException $e) {
         $this->theme->setPreviewImage(null);
         $this->logger->critical($e);
     }
     return $isCopied;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:26,代码来源:Image.php

示例6: publishFile

 /**
  * Publish file
  *
  * @param WriteInterface $rootDir
  * @param WriteInterface $targetDir
  * @param string $sourcePath
  * @param string $destinationPath
  * @return bool
  */
 public function publishFile(WriteInterface $rootDir, WriteInterface $targetDir, $sourcePath, $destinationPath)
 {
     return $rootDir->copyFile($sourcePath, $destinationPath, $targetDir);
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:13,代码来源:Copy.php


注:本文中的Magento\Framework\Filesystem\Directory\WriteInterface::copyFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。