/** * Returns a full path for a given file name. * * @param mixed $name The file name to locate * @param string $currentPath The current path * @param bool $first Whether to return the first occurrence or an array of filenames * * @return string|array The full path to the file|An array of file paths * * @throws \InvalidArgumentException When file is not found */ public function locate($name, $currentPath = null, $first = true) { if ($name instanceof TemplateReference) { $name = $name->getPath(); } if (strpos($name, '@theme_') === 0 && preg_match('/@theme_([^\\/]+)(.+)/', $name, $matches)) { list($fullPath, $themeName, $path) = $matches; $theme = $this->themeManager->getTheme($themeName); if ($theme instanceof ThemeInterface) { $meta = new \ReflectionClass($theme); $file = dirname($meta->getFileName()) . $path; return $file; } } return false; }
/** * {@inheritdoc} */ protected function findTemplate($template) { $templateName = (string) $template; // Only try and load templates which aren't namespaced if (strpos($templateName, '@theme/') === 0) { $templatePath = str_replace('@theme', '', $templateName); $theme = $this->themeManager->getAdminTheme(); return parent::findTemplate('@theme_' . $theme->getName() . $templatePath); } if (strpos($templateName, 'theme_') === 0) { if (preg_match('/theme_([^:]+):([^:]*):(.*)/', $templateName, $matches)) { list($fullName, $themeName, $path, $file) = $matches; $theme = $this->themeManager->getTheme($themeName); return parent::findTemplate('@theme_' . $theme->getName() . $path . '/' . $file); } } return parent::findTemplate($template); }
/** * Get the admin theme namespace */ public function getAdminTheme() { $this->themeManager->getAdminTheme(); }