Пример #1
0
 /**
  * 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;
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * 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);
 }
Пример #4
0
 /**
  * @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();
 }
Пример #5
0
 public function testGetStorageRoot()
 {
     $expectedStorageRoot = '/' . \Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE;
     $this->assertEquals($expectedStorageRoot, $this->helper->getStorageRoot());
 }