rule = $rule; $this->componentRegistrar = $componentRegistrar; } /** * Propagate an underlying fallback rule to every theme in a hierarchy: parent, grandparent, etc. * * @param array $params * @return array * @throws \InvalidArgumentException */ public function getPatternDirs(array $params) { if (!array_key_exists('theme', $params) || !$params['theme'] instanceof ThemeInterface) { throw new \InvalidArgumentException( 'Parameter "theme" should be specified and should implement the theme interface.' ); } $result = []; /** @var $theme ThemeInterface */ $theme = $params['theme']; unset($params['theme']); while ($theme) { if ($theme->getFullPath()) { $params['theme_dir'] = $this->componentRegistrar->getPath( ComponentRegistrar::THEME, $theme->getFullPath() ); $params = $this->getThemePubStaticDir($theme, $params); $result = array_merge($result, $this->rule->getPatternDirs($params)); } $theme = $theme->getParentTheme(); } return $result; } /** * Get dir of Theme that contains published static view files * * @param ThemeInterface $theme * @param array $params * @return array */ private function getThemePubStaticDir(ThemeInterface $theme, $params = []) { if (empty($params['theme_pubstatic_dir']) && isset($params['file']) && pathinfo($params['file'], PATHINFO_EXTENSION) === 'css' ) { $params['theme_pubstatic_dir'] = $this->getDirectoryList() ->getPath(DirectoryList::STATIC_VIEW) . '/' . $theme->getArea() . '/' . $theme->getCode() . (isset($params['locale']) ? '/' . $params['locale'] : ''); } return $params; } /** * Get DirectoryList instance * @return DirectoryList * * @deprecated 101.0.0 */ private function getDirectoryList() { if (null === $this->directoryList) { $this->directoryList = ObjectManager::getInstance()->get(DirectoryList::class); } return $this->directoryList; } }