예제 #1
0
파일: Tree.php 프로젝트: tingyeeh/magento2
 /**
  * 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());
 }