Exemplo n.º 1
0
 /**
  * Get path to minified file
  *
  * @param string $originalFile
  * @return bool|string
  */
 public function getMinifiedFile($originalFile)
 {
     if ($this->_isFileMinified($originalFile)) {
         return $originalFile;
     }
     $originalFileRelative = $this->rootDirectory->getRelativePath($originalFile);
     $minifiedFile = $this->_findOriginalMinifiedFile($originalFileRelative);
     if (!$minifiedFile) {
         $minifiedFile = $this->directoryName . '/' . $this->_generateMinifiedFileName($originalFile);
         $this->_strategy->minifyFile($originalFileRelative, $minifiedFile);
     }
     $minifiedFile = $this->pubViewCacheDir->getRelativePath($minifiedFile);
     return $this->pubViewCacheDir->getAbsolutePath($minifiedFile);
 }
Exemplo n.º 2
0
 /**
  * Get path to custom view configuration file
  *
  * @param \Magento\Framework\View\Design\ThemeInterface $theme
  * @return string|null
  */
 public function getCustomViewConfigPath(\Magento\Framework\View\Design\ThemeInterface $theme)
 {
     $path = null;
     if ($theme->getId()) {
         $path = $this->mediaDirectoryRead->getAbsolutePath(self::DIR_NAME . '/' . $theme->getId() . '/' . $this->filename);
     }
     return $path;
 }
Exemplo n.º 3
0
 /**
  * Return default path related data
  *
  * @param string $configPath
  * @return array
  */
 protected function _preparePathData($configPath)
 {
     $themeDirectory = dirname($configPath);
     $fullPath = trim(substr($themeDirectory, strlen($this->_directory->getAbsolutePath())), '/');
     $pathPieces = explode('/', $fullPath);
     $area = array_shift($pathPieces);
     return ['area' => $area, 'theme_path_pieces' => $pathPieces];
 }
Exemplo n.º 4
0
 /**
  * Fill collection with theme model loaded from filesystem
  *
  * @param bool $printQuery
  * @param bool $logQuery
  * @return $this
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function loadData($printQuery = false, $logQuery = false)
 {
     if ($this->isLoaded()) {
         return $this;
     }
     $pathsToThemeConfig = [];
     foreach ($this->getTargetPatterns() as $directoryPath) {
         $themeConfigs = $this->_directory->search($directoryPath);
         foreach ($themeConfigs as &$relPathToTheme) {
             $relPathToTheme = $this->_directory->getAbsolutePath($relPathToTheme);
         }
         $pathsToThemeConfig = array_merge($pathsToThemeConfig, $themeConfigs);
     }
     $themeConfigs = [];
     foreach ($this->themeDirs->search('/theme.xml') as $themeConfigPath) {
         $themeConfigs[] = $this->rootDirectory->getAbsolutePath($themeConfigPath);
     }
     $pathsToThemeConfig = array_merge($pathsToThemeConfig, $themeConfigs);
     $this->_loadFromFilesystem($pathsToThemeConfig)->clearTargetPatterns()->_updateRelations()->_renderFilters()->_clearFilters();
     return $this;
 }
Exemplo n.º 5
0
 /**
  * Return MIME type of a file.
  *
  * @return string
  */
 public function getContentType()
 {
     $this->_getHandle();
     if ($this->_linkType == self::LINK_TYPE_FILE) {
         if (function_exists('mime_content_type') && ($contentType = mime_content_type($this->_workingDirectory->getAbsolutePath($this->_resourceFile)))) {
             return $contentType;
         } else {
             return $this->_downloadableFile->getFileType($this->_resourceFile);
         }
     } elseif ($this->_linkType == self::LINK_TYPE_URL) {
         return $this->_handle->stat($this->_resourceFile)['type'];
     }
     return $this->_contentType;
 }
Exemplo n.º 6
0
 /**
  * Modify config value and check all changes were written into robots.txt
  */
 protected function _modifyConfig()
 {
     $robotsTxt = "User-Agent: *\nDisallow: /checkout";
     $this->model->setValue($robotsTxt)->save();
     $this->assertStringEqualsFile($this->rootDirectory->getAbsolutePath('robots.txt'), $robotsTxt);
 }