當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Write::getRelativePath方法代碼示例

本文整理匯總了PHP中Magento\Framework\Filesystem\Directory\Write::getRelativePath方法的典型用法代碼示例。如果您正苦於以下問題:PHP Write::getRelativePath方法的具體用法?PHP Write::getRelativePath怎麽用?PHP Write::getRelativePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Filesystem\Directory\Write的用法示例。


在下文中一共展示了Write::getRelativePath方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: resizeFile

 /**
  * Create thumbnail for image and save it to thumbnails directory
  *
  * @param string $source Image path to be resized
  * @param bool $keepRation Keep aspect ratio or not
  * @return bool|string Resized filepath or false if errors were occurred
  */
 public function resizeFile($source, $keepRation = true)
 {
     $realPath = $this->_directory->getRelativePath($source);
     if (!$this->_directory->isFile($realPath) || !$this->_directory->isExist($realPath)) {
         return false;
     }
     $targetDir = $this->getThumbsPath($source);
     $pathTargetDir = $this->_directory->getRelativePath($targetDir);
     if (!$this->_directory->isExist($pathTargetDir)) {
         $this->_directory->create($pathTargetDir);
     }
     if (!$this->_directory->isExist($pathTargetDir)) {
         return false;
     }
     $image = $this->_imageFactory->create();
     $image->open($source);
     $image->keepAspectRatio($keepRation);
     $image->resize($this->_resizeParameters['width'], $this->_resizeParameters['height']);
     $dest = $targetDir . '/' . pathinfo($source, PATHINFO_BASENAME);
     $image->save($dest);
     if ($this->_directory->isFile($this->_directory->getRelativePath($dest))) {
         return $dest;
     }
     return false;
 }
開發者ID:tingyeeh,項目名稱:magento2,代碼行數:32,代碼來源:Storage.php

示例2: getCurrentUrl

 /**
  * Return URL based on current selected directory or root directory for startup
  *
  * @return string
  */
 public function getCurrentUrl()
 {
     if (!$this->_currentUrl) {
         $path = $this->getCurrentPath();
         $mediaUrl = $this->_storeManager->getStore($this->_storeId)->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
         $this->_currentUrl = $mediaUrl . $this->_directory->getRelativePath($path) . '/';
     }
     return $this->_currentUrl;
 }
開發者ID:pavelnovitsky,項目名稱:magento2,代碼行數:14,代碼來源:Images.php

示例3: testGetCurrentPath

 /**
  * @param string $pathId
  * @param string $expectedPath
  * @param bool $isExist
  * @dataProvider providerGetCurrentPath
  */
 public function testGetCurrentPath($pathId, $expectedPath, $isExist)
 {
     $this->requestMock->expects($this->once())->method('getParam')->willReturn($pathId);
     $this->directoryWriteMock->expects($this->any())->method('isDirectory')->willReturnMap([['/../wysiwyg/test_path', true], ['/../wysiwyg/my.jpg', false], ['/../wysiwyg', true]]);
     $this->directoryWriteMock->expects($this->any())->method('getRelativePath')->willReturnMap([['PATH/wysiwyg/test_path', '/../wysiwyg/test_path'], ['PATH/wysiwyg/my.jpg', '/../wysiwyg/my.jpg'], ['PATH/wysiwyg', '/../wysiwyg']]);
     $this->directoryWriteMock->expects($this->once())->method('isExist')->willReturn($isExist);
     $this->directoryWriteMock->expects($this->any())->method('create')->with($this->directoryWriteMock->getRelativePath($expectedPath));
     $this->assertEquals($expectedPath, $this->imagesHelper->getCurrentPath());
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:15,代碼來源:ImagesTest.php

示例4: __construct

 /**
  * Open file and detect column names
  *
  * There must be column names in the first line
  *
  * @param string $file
  * @param \Magento\Framework\Filesystem\Directory\Write $directory
  * @param string $delimiter
  * @param string $enclosure
  * @throws \LogicException
  */
 public function __construct($file, \Magento\Framework\Filesystem\Directory\Write $directory, $delimiter = ',', $enclosure = '"')
 {
     try {
         $this->_file = $directory->openFile($directory->getRelativePath($file), 'r');
     } catch (\Magento\Framework\Filesystem\FilesystemException $e) {
         throw new \LogicException("Unable to open file: '{$file}'");
     }
     $this->_delimiter = $delimiter;
     $this->_enclosure = $enclosure;
     parent::__construct($this->_getNextRow());
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:22,代碼來源:Csv.php

示例5: deleteFile

 /**
  * Delete file
  *
  * @param string $file
  * @return \Magento\Theme\Model\Wysiwyg\Storage
  */
 public function deleteFile($file)
 {
     $file = $this->urlDecoder->decode($file);
     $path = $this->mediaWriteDirectory->getRelativePath($this->_helper->getCurrentPath());
     $filePath = $this->mediaWriteDirectory->getRelativePath($path . '/' . $file);
     $thumbnailPath = $this->_helper->getThumbnailDirectory($filePath) . '/' . $file;
     if (0 === strpos($filePath, $path) && 0 === strpos($filePath, $this->_helper->getStorageRoot())) {
         $this->mediaWriteDirectory->delete($filePath);
         $this->mediaWriteDirectory->delete($thumbnailPath);
     }
     return $this;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:18,代碼來源:Storage.php

示例6: collectFolders

 /**
  * Get all folders as options array
  *
  * @return array
  */
 public function collectFolders()
 {
     $collectFiles = $this->_collectFiles;
     $collectDirs = $this->_collectDirs;
     $this->setCollectFiles(false)->setCollectDirs(true);
     $this->_collectRecursive($this->connectDirectory->getAbsolutePath('connect'));
     $result = array('/' => '/');
     foreach ($this->_collectedDirs as $dir) {
         $dir = substr($this->connectDirectory->getRelativePath($dir), strlen('connect/')) . '/';
         $result[$dir] = $dir;
     }
     $this->setCollectFiles($collectFiles)->setCollectDirs($collectDirs);
     return $result;
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:19,代碼來源:Collection.php

示例7: getCurrentPath

 /**
  * Get current path
  *
  * @return string
  */
 public function getCurrentPath()
 {
     if (!$this->_currentPath) {
         $currentPath = $this->getStorageRoot();
         $path = $this->_getRequest()->getParam(self::PARAM_NODE);
         if ($path && $path !== self::NODE_ROOT) {
             $path = $this->convertIdToPath($path);
             if ($this->mediaDirectoryWrite->isDirectory($path) && 0 === strpos($path, $currentPath)) {
                 $currentPath = $this->mediaDirectoryWrite->getRelativePath($path);
             }
         }
         $this->_currentPath = $currentPath;
     }
     return $this->_currentPath;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:20,代碼來源:Storage.php

示例8: __construct

 /**
  * @param string $file
  * @param \Magento\Framework\Filesystem\Directory\Write $directory
  * @param string $options
  */
 public function __construct($file, \Magento\Framework\Filesystem\Directory\Write $directory, $options)
 {
     $zip = new \Magento\Framework\Archive\Zip();
     $file = $zip->unpack($directory->getRelativePath($file), $directory->getRelativePath(preg_replace('/\\.zip$/i', '.csv', $file)));
     parent::__construct($file, $directory, $options);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:11,代碼來源:Zip.php

示例9: tearDownAfterClass

 public static function tearDownAfterClass()
 {
     self::$_varDirectory->delete(self::$_varDirectory->getRelativePath(self::$_tmpDir));
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:4,代碼來源:ConfigTest.php


注:本文中的Magento\Framework\Filesystem\Directory\Write::getRelativePath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。