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


PHP WriteInterface::getAbsolutePath方法代码示例

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


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

示例1: createFile

 /**
  * Write down contents to a temporary file and return its absolute path
  *
  * @param string $relativePath
  * @param string $contents
  * @return string
  */
 public function createFile($relativePath, $contents)
 {
     $filePath = $this->config->getLessMaterializationRelativePath() . '/' . $relativePath;
     if (!$this->tmpDirectory->isExist($filePath)) {
         $this->tmpDirectory->writeFile($filePath, $contents);
     }
     return $this->tmpDirectory->getAbsolutePath($filePath);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:Temporary.php

示例2: setUp

 protected function setUp()
 {
     $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $filesystem = $this->_objectManager->create('Magento\\Framework\\App\\Filesystem');
     $this->_varDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::VAR_DIR);
     $fullFileName = $this->_varDirectory->getAbsolutePath(self::FILE_PATH);
     $this->_testFileHandler = fopen($fullFileName, 'w');
 }
开发者ID:aiesh,项目名称:magento2,代码行数:8,代码来源:FileTest.php

示例3: uploadFromTmp

 /**
  * Upload file from temporary folder.
  * @param string $tmpPath
  * @param \Magento\Core\Model\File\Uploader $uploader
  * @return array
  */
 public function uploadFromTmp($tmpPath, \Magento\Core\Model\File\Uploader $uploader)
 {
     $uploader->setAllowRenameFiles(true);
     $uploader->setFilesDispersion(true);
     $absoluteTmpPath = $this->_mediaDirectory->getAbsolutePath($tmpPath);
     $result = $uploader->save($absoluteTmpPath);
     return $result;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:File.php

示例4: execute

 /**
  * Flash ISM_BaseRunner cache
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $dir = $this->_mediaDirectory->getAbsolutePath(Upload::UPLOAD_POST_IMAGE_DIR . 'cache/');
     if (is_dir($dir)) {
         $dir = $this->_mediaDirectory->getDriver()->readDirectory($dir);
         foreach ($dir as $file) {
             $this->_mediaDirectory->delete(Upload::UPLOAD_POST_IMAGE_DIR . 'cache/' . basename($file));
         }
     }
 }
开发者ID:swnsma,项目名称:practice,代码行数:16,代码来源:FlushAllCache.php

示例5: _generateRow

 /**
  * Get backup-specific data from model for each row
  *
  * @param string $filename
  * @return array
  */
 protected function _generateRow($filename)
 {
     $row = parent::_generateRow($filename);
     foreach ($this->_backup->load($row['basename'], $this->_varDirectory->getAbsolutePath($this->_path))->getData() as $key => $value) {
         $row[$key] = $value;
     }
     $row['size'] = $this->_varDirectory->stat($this->_varDirectory->getRelativePath($filename))['size'];
     $row['id'] = $row['time'] . '_' . $row['type'];
     return $row;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:Collection.php

示例6: getCertPath

 /**
  * Get path to PayPal certificate file, if file does not exist try to create it
  *
  * @return string
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function getCertPath()
 {
     if (!$this->getContent()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The PayPal certificate does not exist.'));
     }
     $certFileName = sprintf('cert_%s_%s.pem', $this->getWebsiteId(), strtotime($this->getUpdatedAt()));
     $certFile = self::BASEPATH_PAYPAL_CERT . $certFileName;
     if (!$this->varDirectory->isExist($certFile)) {
         $this->_createCertFile($certFile);
     }
     return $this->varDirectory->getAbsolutePath($certFile);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:Cert.php

示例7: _generateRow

 /**
  * Get backup-specific data from model for each row
  *
  * @param string $filename
  * @return array
  */
 protected function _generateRow($filename)
 {
     $row = parent::_generateRow($filename);
     foreach ($this->_backup->load($row['basename'], $this->_varDirectory->getAbsolutePath($this->_path))->getData() as $key => $value) {
         $row[$key] = $value;
     }
     $row['size'] = $this->_varDirectory->stat($this->_varDirectory->getRelativePath($filename))['size'];
     if (isset($row['display_name']) && $row['display_name'] == '') {
         $row['display_name'] = 'WebSetupWizard';
     }
     $row['id'] = $row['time'] . '_' . $row['type'] . (isset($row['display_name']) ? $row['display_name'] : '');
     return $row;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:Collection.php

示例8: unpackDb

 /**
  * @param string $dbCode
  * @throws LocalizedException
  */
 protected function unpackDb($dbCode)
 {
     $this->archive->unpack($this->directory->getAbsolutePath($this->getDbArchiveFilePath($dbCode)), $this->directory->getAbsolutePath($this->database->getDbPath($dbCode)));
     if (!$this->directory->isExist($this->database->getDbPath($dbCode))) {
         throw new LocalizedException(__('Cannot unpack db file.'));
     }
 }
开发者ID:ytorbyk,项目名称:magento2-geo-ip2,代码行数:11,代码来源:Updater.php

示例9: saveFileToTmpDir

 /**
  * Checking file for save and save it to tmp dir
  *
  * @param string $fileId
  *
  * @return string[]
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function saveFileToTmpDir($fileId)
 {
     $baseTmpPath = $this->getBaseTmpPath();
     $uploader = $this->uploaderFactory->create(['fileId' => $fileId]);
     $uploader->setAllowedExtensions($this->getAllowedExtensions());
     $uploader->setAllowRenameFiles(true);
     $result = $uploader->save($this->mediaDirectory->getAbsolutePath($baseTmpPath));
     if (!$result) {
         throw new \Magento\Framework\Exception\LocalizedException(__('File can not be saved to the destination folder.'));
     }
     /**
      * Workaround for prototype 1.7 methods "isJSON", "evalJSON" on Windows OS
      */
     $result['tmp_name'] = str_replace('\\', '/', $result['tmp_name']);
     $result['path'] = str_replace('\\', '/', $result['path']);
     $result['url'] = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $this->getFilePath($baseTmpPath, $result['file']);
     $result['name'] = $result['file'];
     if (isset($result['file'])) {
         try {
             $relativePath = rtrim($baseTmpPath, '/') . '/' . ltrim($result['file'], '/');
             $this->coreFileStorageDatabase->saveFile($relativePath);
         } catch (\Exception $e) {
             $this->logger->critical($e);
             throw new \Magento\Framework\Exception\LocalizedException(__('Something went wrong while saving the file(s).'));
         }
     }
     return $result;
 }
开发者ID:ant-workaholic,项目名称:Store-locator,代码行数:37,代码来源:ImageUploader.php

示例10: preProcess

    /**
     * Perform necessary preprocessing and materialization when the specified asset is requested
     *
     * Returns an array of two elements:
     * - directory where the file is supposed to be found
     * - relative path to the file
     *
     * returns false if source file was not found
     *
     * @param LocalInterface $asset
     * @return array|bool
     */
    private function preProcess(LocalInterface $asset)
    {
        $sourceFile = $this->findSourceFile($asset);
        $dir = $this->rootDir->getAbsolutePath();
        $path = '';
        if ($sourceFile) {
            $path = basename($sourceFile);
            $dir = dirname($sourceFile);
        }

        $chain = $this->createChain($asset, $dir, $path);
        $this->preProcessorPool->process($chain);
        $chain->assertValid();
        if ($chain->isChanged()) {
            $dir = $this->varDir->getAbsolutePath();
            $path = DirectoryList::TMP_MATERIALIZATION_DIR . '/source/' . $chain->getTargetAssetPath();
            $this->varDir->writeFile($path, $chain->getContent());
        }
        if (empty($path)) {
            $result = false;
        } else {
            $result = [$dir, $path];
        }
        return $result;
    }
开发者ID:rafaelstz,项目名称:magento2,代码行数:37,代码来源:Source.php

示例11: saveImage

 /**
  * Save new image and remove old image.
  *
  * @param $file string new file
  * @param $old  string old file
  *
  * @return string file name
  * @throws LocalizedException
  */
 public function saveImage($file, $old)
 {
     $uploadDir = $this->_mediaDirectory->getAbsolutePath(self::UPLOAD_POST_IMAGE_DIR);
     try {
         $uploader = $this->_uploaderFactory->create(['fileId' => $file]);
         $uploader->setAllowedExtensions(self::TYPES_ALLOWED);
         $uploader->setAllowRenameFiles(true);
         $uploader->addValidateCallback('size', $this, 'validateMaxSize');
         $result = $uploader->save($uploadDir);
     } catch (\Exception $e) {
         throw new LocalizedException(__($e->getMessage()));
     }
     if ($old) {
         $this->removeImage($old);
     }
     return $result['file'];
 }
开发者ID:swnsma,项目名称:practice,代码行数:26,代码来源:Upload.php

示例12: getUniqueFileName

 /**
  * Check whether file to move exists. Getting unique name
  *
  * @param string $file
  * @param bool $forTmp
  * @return string
  */
 protected function getUniqueFileName($file, $forTmp = false)
 {
     if ($this->fileStorageDb->checkDbUsage()) {
         $destFile = $this->fileStorageDb->getUniqueFilename($this->mediaConfig->getBaseMediaUrlAddition(), $file);
     } else {
         $destinationFile = $forTmp ? $this->mediaDirectory->getAbsolutePath($this->mediaConfig->getTmpMediaPath($file)) : $this->mediaDirectory->getAbsolutePath($this->mediaConfig->getMediaPath($file));
         $destFile = dirname($file) . '/' . \Magento\MediaStorage\Model\File\Uploader::getNewFileName($destinationFile);
     }
     return $destFile;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:AbstractMedia.php

示例13: _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

示例14: checkAndCreate

 /**
  * Check thumbnail and create it if need.
  *
  * @return bool
  */
 public function checkAndCreate()
 {
     if ($this->_mediaDirectory->isFile($this->_cacheDir . $this->_post->getImageUrl())) {
         return true;
     }
     if (!$this->_mediaDirectory->isFile(Upload::UPLOAD_POST_IMAGE_DIR . $this->_post->getImageUrl())) {
         return false;
     }
     $image = $this->_imageFactory->create(array('file' => $this->_mediaDirectory->getAbsolutePath(Upload::UPLOAD_POST_IMAGE_DIR . $this->_post->getImageUrl())));
     $image->setWH(75, 75);
     $image->resize();
     $image->save(DirectoryList::PUB . DIRECTORY_SEPARATOR . DirectoryList::MEDIA . DIRECTORY_SEPARATOR . $this->_cacheDir . $this->_post->getImageUrl());
     return true;
 }
开发者ID:swnsma,项目名称:practice,代码行数:19,代码来源:Thumbnail.php

示例15: getDestinationDirectory

 /**
  * Retrieve destination directory for given content type
  *
  * @param string $contentType
  * @return string
  * @throws \InvalidArgumentException
  */
 protected function getDestinationDirectory($contentType)
 {
     switch ($contentType) {
         case 'link_file':
             $directory = $this->mediaDirectory->getAbsolutePath($this->linkConfig->getBaseTmpPath());
             break;
         case 'link_sample_file':
             $directory = $this->mediaDirectory->getAbsolutePath($this->linkConfig->getBaseSampleTmpPath());
             break;
         case 'sample':
             $directory = $this->mediaDirectory->getAbsolutePath($this->sampleConfig->getBaseTmpPath());
             break;
         default:
             throw new \InvalidArgumentException('Invalid downloadable file content type.');
     }
     return $directory;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:24,代码来源:ContentUploader.php


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