fileListFactory = $fileListFactory; $this->libraryDirectory = $filesystem->getDirectoryRead( DirectoryList::LIB_WEB ); $this->fileFactory = $fileFactory; $this->readFactory = $readFactory; $this->componentRegistrar = $componentRegistrar; } /** * 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(); } /** * @param ReadInterface $reader * @param ThemeInterface $theme * @param array $files * @return array */ protected function createFiles(ReadInterface $reader, ThemeInterface $theme, $files) { $result = []; foreach ($files as $file) { $filename = $reader->getAbsolutePath($file); $result[] = $this->fileFactory->create($filename, false, $theme); } return $result; } }