當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。