当前位置: 首页>>代码示例>>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;未经允许,请勿转载。