/**
  * Retrieve files
  *
  * @param ThemeInterface $theme
  * @param string $filePath
  * @return array|\Magento\Framework\View\File[]
  * @throws \Magento\Framework\Exception
  */
 public function getFiles(ThemeInterface $theme, $filePath)
 {
     $namespace = $module = '*';
     $themePath = $theme->getFullPath();
     $searchPattern = "{$themePath}/{$namespace}_{$module}/{$this->subDir}*/*/{$filePath}";
     $files = $this->themesDirectory->search($searchPattern);
     if (empty($files)) {
         return [];
     }
     $themes = [];
     $currentTheme = $theme;
     while ($currentTheme = $currentTheme->getParentTheme()) {
         $themes[$currentTheme->getCode()] = $currentTheme;
     }
     $result = [];
     $pattern = "#/(?<module>[^/]+)/{$this->subDir}(?<themeVendor>[^/]+)/(?<themeName>[^/]+)/" . strtr(preg_quote($filePath), ['\\*' => '[^/]+']) . "\$#i";
     foreach ($files as $file) {
         $filename = $this->themesDirectory->getAbsolutePath($file);
         if (!preg_match($pattern, $filename, $matches)) {
             continue;
         }
         $moduleFull = $matches['module'];
         $ancestorThemeCode = $matches['themeVendor'] . '/' . $matches['themeName'];
         if (!isset($themes[$ancestorThemeCode])) {
             throw new Exception(sprintf("Trying to override modular view file '%s' for theme '%s', which is not ancestor of theme '%s'", $filename, $ancestorThemeCode, $theme->getCode()));
         }
         $result[] = $this->fileFactory->create($filename, $moduleFull, $themes[$ancestorThemeCode]);
     }
     return $result;
 }
Example #2
0
 /**
  * Retrieve files
  *
  * @param ThemeInterface $theme
  * @param string $filePath
  * @return array|\Magento\Framework\View\File[]
  */
 public function getFiles(ThemeInterface $theme, $filePath)
 {
     $result = [];
     $namespace = $module = '*';
     $sharedFiles = $this->modulesDirectory->search("{$namespace}/{$module}/view/base/{$this->subDir}{$filePath}");
     $filePathPtn = strtr(preg_quote($filePath), ['\\*' => '[^/]+']);
     $pattern = "#(?<namespace>[^/]+)/(?<module>[^/]+)/view/base/{$this->subDir}" . $filePathPtn . "\$#i";
     foreach ($sharedFiles as $file) {
         $filename = $this->modulesDirectory->getAbsolutePath($file);
         if (!preg_match($pattern, $filename, $matches)) {
             continue;
         }
         $moduleFull = "{$matches['namespace']}_{$matches['module']}";
         $result[] = $this->fileFactory->create($filename, $moduleFull, null, true);
     }
     $area = $theme->getData('area');
     $themeFiles = $this->modulesDirectory->search("{$namespace}/{$module}/view/{$area}/{$this->subDir}{$filePath}");
     $pattern = "#(?<namespace>[^/]+)/(?<module>[^/]+)/view/{$area}/{$this->subDir}" . $filePathPtn . "\$#i";
     foreach ($themeFiles as $file) {
         $filename = $this->modulesDirectory->getAbsolutePath($file);
         if (!preg_match($pattern, $filename, $matches)) {
             continue;
         }
         $moduleFull = "{$matches['namespace']}_{$matches['module']}";
         $result[] = $this->fileFactory->create($filename, $moduleFull);
     }
     return $result;
 }
Example #3
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function get($filename, $scope)
 {
     $configPaths = $this->configDirectory->search('{*' . $filename . ',*/*' . $filename . '}');
     $configAbsolutePaths = [];
     foreach ($configPaths as $configPath) {
         $configAbsolutePaths[] = $this->configDirectory->getAbsolutePath($configPath);
     }
     return $this->iteratorFactory->create($configAbsolutePaths);
 }
Example #4
0
 /**
  * Retrieve files
  *
  * @param ThemeInterface $theme
  * @param string $filePath
  * @return array|\Magento\Framework\View\File[]
  */
 public function getFiles(ThemeInterface $theme, $filePath)
 {
     $themePath = $theme->getFullPath();
     $files = $this->themesDirectory->search("{$themePath}/{$this->subDir}{$filePath}");
     $result = [];
     foreach ($files as $file) {
         $filename = $this->themesDirectory->getAbsolutePath($file);
         $result[] = $this->fileFactory->create($filename, null, $theme);
     }
     return $result;
 }
Example #5
0
 /**
  * Retrieve files
  *
  * @param ThemeInterface $theme
  * @param string $filePath
  * @return array|\Magento\Framework\View\File[]
  */
 public function getFiles(ThemeInterface $theme, $filePath)
 {
     $list = $this->fileListFactory->create();
     $files = $this->libraryDirectory->search($filePath);
     $list->add($this->createFiles($this->libraryDirectory, $theme, $files));
     foreach ($theme->getInheritedThemes() as $currentTheme) {
         $themeFullPath = $currentTheme->getFullPath();
         $files = $this->themesDirectory->search("{$themeFullPath}/web/{$filePath}");
         $list->replace($this->createFiles($this->themesDirectory, $theme, $files), false);
     }
     return $list->getAll();
 }
Example #6
0
 /**
  * Retrieve files
  *
  * @param ThemeInterface $theme
  * @param string $filePath
  * @return array|\Magento\Framework\View\File[]
  */
 public function getFiles(ThemeInterface $theme, $filePath)
 {
     $list = $this->fileListFactory->create('Magento\\Framework\\Less\\File\\FileList\\Collator');
     $files = $this->libraryDirectory->search($filePath);
     $list->add($this->createFiles($this->libraryDirectory, $theme, $files));
     foreach ($theme->getInheritedThemes() as $currentTheme) {
         $themeFullPath = $currentTheme->getFullPath();
         $files = $this->rootDirectory->search("web/{$filePath}", $this->themeDir->getPathByKey($themeFullPath));
         //$files = $this->themesDirectory->search("{$themeFullPath}/web/{$filePath}");
         $list->replace($this->createFiles($this->themesDirectory, $theme, $files), false);
     }
     return $list->getAll();
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function get($filename, $scope)
 {
     switch ($scope) {
         case 'global':
             $iterator = $this->_moduleReader->getConfigurationFiles($filename);
             break;
         case 'design':
             $iterator = $this->iteratorFactory->create($this->themesDirectory, $this->themesDirectory->search('/*/*/etc/' . $filename));
             break;
         default:
             $iterator = $this->iteratorFactory->create($this->themesDirectory, array());
             break;
     }
     return $iterator;
 }
Example #8
0
 /**
  * Retrieve files
  *
  * @param ThemeInterface $theme
  * @param string $filePath
  * @return array|\Magento\Framework\View\File[]
  */
 public function getFiles(ThemeInterface $theme, $filePath)
 {
     $namespace = $module = '*';
     $themePath = $theme->getFullPath();
     $files = $this->themesDirectory->search("{$themePath}/{$namespace}_{$module}/{$this->subDir}{$filePath}");
     $result = array();
     $pattern = "#/(?<moduleName>[^/]+)/{$this->subDir}" . strtr(preg_quote($filePath), array('\\*' => '[^/]+')) . "\$#i";
     foreach ($files as $file) {
         $filename = $this->themesDirectory->getAbsolutePath($file);
         if (!preg_match($pattern, $filename, $matches)) {
             continue;
         }
         $result[] = $this->fileFactory->create($filename, $matches['moduleName'], $theme);
     }
     return $result;
 }
Example #9
0
 /**
  * Retrieve files
  *
  * @param ThemeInterface $theme
  * @param string $filePath
  * @return \Magento\Framework\View\File[]
  */
 public function getFiles(ThemeInterface $theme, $filePath)
 {
     $list = $this->fileListFactory->create('Magento\\Framework\\Css\\PreProcessor\\File\\FileList\\Collator');
     $files = $this->libraryDirectory->search($filePath);
     $list->add($this->createFiles($this->libraryDirectory, $theme, $files));
     foreach ($theme->getInheritedThemes() as $currentTheme) {
         $themeFullPath = $currentTheme->getFullPath();
         $path = $this->componentRegistrar->getPath(ComponentRegistrar::THEME, $themeFullPath);
         if (empty($path)) {
             continue;
         }
         $directoryRead = $this->readFactory->create($path);
         $foundFiles = $directoryRead->search("web/{$filePath}");
         $list->replace($this->createFiles($directoryRead, $theme, $foundFiles));
     }
     return $list->getAll();
 }
Example #10
0
 /**
  * Find all theme-based email templates for a given template ID
  *
  * @param string $templateId
  * @return array[]
  */
 public function getThemeTemplates($templateId)
 {
     $templates = [];
     $area = $this->getTemplateArea($templateId);
     $themePath = '*/*';
     $module = $this->getTemplateModule($templateId);
     $filename = $this->_getInfo($templateId, 'file');
     $searchPattern = "{$area}/{$themePath}/{$module}/email/{$filename}";
     $files = $this->themesDirectory->search($searchPattern);
     $pattern = "#^(?<area>[^/]+)/(?<themeVendor>[^/]+)/(?<themeName>[^/]+)/#i";
     foreach ($files as $file) {
         if (!preg_match($pattern, $file, $matches)) {
             continue;
         }
         $themeVendor = $matches['themeVendor'];
         $themeName = $matches['themeName'];
         $templates[] = ['value' => sprintf('%s/%s/%s', $templateId, $themeVendor, $themeName), 'label' => sprintf('%s (%s/%s)', $this->getTemplateLabel($templateId), $themeVendor, $themeName), 'group' => $this->getTemplateModule($templateId)];
     }
     return $templates;
 }
Example #11
0
 /**
  * Read the CSV-files in a language package
  *
  * The files are sorted alphabetically, then each of them is read, and results are recorded into key => value array
  *
  * @param string $vendor
  * @param string $package
  * @return array
  */
 private function readPackCsv($vendor, $package)
 {
     $files = $this->dir->search("{$vendor}/{$package}/*.csv");
     sort($files);
     $result = [];
     foreach ($files as $path) {
         $file = $this->dir->openFile($path);
         while (($row = $file->readCsv()) !== false) {
             $result[$row[0]] = $row[1];
         }
     }
     return $result;
 }
Example #12
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function get($filename, $scope)
 {
     return $this->iteratorFactory->create($this->configDirectory, $this->configDirectory->search('{*' . $filename . ',*/*' . $filename . '}'));
 }
Example #13
0
 /**
  * {@inheritdoc}
  */
 public function get($filename, $scope)
 {
     $iterator = $this->iteratorFactory->create($this->directoryRead, $this->directoryRead->search('/*/*/etc/data_source/' . $filename));
     return $iterator;
 }