> */ protected static array $info = []; public function __construct() { $this->config = config('Themes'); } /** * Sets the active theme. */ public static function setTheme(string $theme): void { static::$currentTheme = $theme; } /** * Returns the path to the specified theme folder. If no theme is provided, will use the current theme. */ public static function path(string $theme = null): string { if ($theme === null) { $theme = static::current(); } // Ensure we've pulled the theme info if (static::$info === []) { static::$info = self::available(); } foreach (static::$info as $info) { if ($info['name'] === $theme) { return $info['path']; } } return ''; } /** * Returns the name of the active theme. */ public static function current(): string { return static::$currentTheme ?? static::$defaultTheme; } /** * Returns an array of all available themes and the paths to their directories. * * @return array> */ public static function available(): array { $themes = []; $config = config('Themes'); foreach ($config->themes as $name => $folder) { $themes[] = [ 'name' => $name, 'path' => $config->themesDirectory . '/' . $folder . '/', ]; } return $themes; } }