/** * Return tree node full path based on current path * * @return string */ public function getTreeCurrentPath() { $treePath = '/root'; $path = $this->_storageHelper->getSession()->getCurrentPath(); if ($path) { $path = str_replace($this->_storageHelper->getStorageRoot(), '', $path); $relative = ''; foreach (explode('/', $path) as $dirName) { if ($dirName) { $relative .= '/' . $dirName; $treePath .= '/' . $this->urlEncoder->encode($relative); } } } return $treePath; }
/** * Copy file to tmp theme customization path * * @param string $sourceFile * @return string */ protected function _copyFileToTmpCustomizationPath($sourceFile) { $targetFile = $this->_helperStorage->getStorageRoot() . '/' . basename($sourceFile); $this->directoryTmp->create(pathinfo($targetFile, PATHINFO_DIRNAME)); $this->directoryVar->copyFile($this->directoryVar->getRelativePath($sourceFile), $this->directoryTmp->getRelativePath($targetFile), $this->directoryTmp); return $targetFile; }
/** * Delete directory * * @param string $path * @return bool * @throws \Magento\Framework\Exception\LocalizedException */ public function deleteDirectory($path) { $rootCmp = rtrim($this->_helper->getStorageRoot(), '/'); $pathCmp = rtrim($path, '/'); if ($rootCmp == $pathCmp) { throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t delete root directory %1 right now.', $path)); } return $this->mediaWriteDirectory->delete($path); }
/** * @test * @return void * @expectedException \InvalidArgumentException * @expectedExceptionMessage Theme was not found */ public function testGetThemeNotFound() { $this->themeFactory->expects($this->once())->method('create')->willReturn(null); $helper = new \Magento\Theme\Helper\Storage($this->contextHelper, $this->filesystem, $this->session, $this->themeFactory); $helper->getStorageRoot(); }
public function testGetStorageRoot() { $expectedStorageRoot = '/' . \Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE; $this->assertEquals($expectedStorageRoot, $this->helper->getStorageRoot()); }