27 private $pathPatternHelper;
41 private $readDirFactory;
48 private $componentRegistrar;
67 FileFactory $fileFactory,
73 $this->pathPatternHelper = $pathPatternHelper;
74 $this->fileFactory = $fileFactory;
75 $this->readDirFactory = $readDirFactory;
77 $this->subDir = $subDir ? $subDir .
'/' :
'';
91 $themePath =
$theme->getFullPath();
92 if (empty($themePath)) {
95 $themeAbsolutePath = $this->componentRegistrar->getPath(ComponentRegistrar::THEME, $themePath);
96 if (!$themeAbsolutePath) {
99 $themeDir = $this->readDirFactory->create($themeAbsolutePath);
100 $files = $themeDir->search(
"{$namespace}_{$module}/{$this->subDir}*/*/{$filePath}");
107 while ($currentTheme = $currentTheme->getParentTheme()) {
108 $themes[$currentTheme->getCode()] = $currentTheme;
111 $pattern =
"#/(?<module>[^/]+)/{$this->subDir}(?<themeVendor>[^/]+)/(?<themeName>[^/]+)/" 112 . $this->pathPatternHelper->translatePatternFromGlob($filePath) .
"$#i";
113 foreach (
$files as $file) {
114 $filename = $themeDir->getAbsolutePath($file);
118 $moduleFull = $matches[
'module'];
119 $ancestorThemeCode = $matches[
'themeVendor'] .
'/' . $matches[
'themeName'];
120 if (!isset($themes[$ancestorThemeCode])) {
123 "Trying to override modular view file '%1' for theme '%2', which is not ancestor of theme '%3'",
128 $result[] = $this->fileFactory->create(
$filename, $moduleFull, $themes[$ancestorThemeCode]);
getFiles(ThemeInterface $theme, $filePath)
__construct(FileFactory $fileFactory, ReadFactory $readDirFactory, ComponentRegistrarInterface $componentRegistrar, PathPattern $pathPatternHelper, $subDir='')
foreach($appDirs as $dir) $files