pathPatternHelper = $pathPatternHelper; $this->fileFactory = $fileFactory; $this->readDirFactory = $readDirFactory; $this->componentRegistrar = $componentRegistrar; $this->subDir = $subDir ? $subDir . '/' : ''; } /** * Retrieve files * * @param \Magento\Framework\View\Design\ThemeInterface $theme * @param string $filePath * @return \Magento\Framework\View\File[] */ public function getFiles(ThemeInterface $theme, $filePath) { $namespace = $module = '*'; $themePath = $theme->getFullPath(); if (empty($themePath)) { return []; } $themeAbsolutePath = $this->componentRegistrar->getPath(ComponentRegistrar::THEME, $themePath); if (!$themeAbsolutePath) { return []; } $themeDir = $this->readDirFactory->create($themeAbsolutePath); $files = $themeDir->search("{$namespace}_{$module}/{$this->subDir}$filePath"); $result = []; $pattern = "#/(?[^/]+)/{$this->subDir}" . $this->pathPatternHelper->translatePatternFromGlob($filePath) . "$#i"; foreach ($files as $file) { $filename = $themeDir->getAbsolutePath($file); if (!preg_match($pattern, $filename, $matches)) { continue; } $result[] = $this->fileFactory->create($filename, $matches['moduleName'], $theme); } return $result; } }