本文整理汇总了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;
}
示例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;
}
示例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());
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例9: tearDownAfterClass
public static function tearDownAfterClass()
{
self::$_varDirectory->delete(self::$_varDirectory->getRelativePath(self::$_tmpDir));
}