public function set($themeName)
{
if (!Config::get('themes.enabled', true)) {
return;
}
if (!($theme = $this->find($themeName))) {
$theme = $this->add(new Theme($themeName));
}
$this->activeTheme = $theme;
// Build Paths array.
// All paths are relative to Config::get('theme.theme_path')
$paths = [];
do {
if (substr($theme->viewsPath, 0, 1) === DIRECTORY_SEPARATOR) {
$path = base_path(substr($theme->viewsPath, 1));
} else {
$path = $this->themesPath;
$path .= empty($theme->viewsPath) ? '' : DIRECTORY_SEPARATOR . $theme->viewsPath;
}
if (!in_array($path, $paths)) {
$paths[] = $path;
}
} while ($theme = $theme->getParent());
// fall-back to default paths (set in views.php config file)
foreach ($this->defaultViewsPath as $path) {
if (!in_array($path, $paths)) {
$paths[] = $path;
}
}
Config::set('view.paths', $paths);
$themeViewFinder = app('view.finder');
$themeViewFinder->setPaths($paths);
\Event::fire('igaster.laravel-theme.change', $this->activeTheme);
}