ldc-gen-game-web/app/Helpers/ThemeHelper.php

38 lines
1.2 KiB
PHP
Raw Normal View History

<?php
2025-07-25 17:21:23 +02:00
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
if (!function_exists('themeConfig')) {
/**
* Undocumented function
*
* @return array
* @throws \Exception Folder or config file doesn't exist.
*/
function themeConfig(): array
{
2025-07-25 17:21:23 +02:00
$themeName = tenant()->theme;
return Cache::remember("config-$themeName", 84600, function () use ($themeName) {
$themePath = resource_path("theme/$themeName");
$configFile = "$themePath/theme.config.php";
2025-07-25 17:21:23 +02:00
if (!is_dir($themePath)) {
Log::error("Le dossier du thème [$themeName] est introuvable : $themePath");
throw new \Exception(
"Le dossier du thème [$themeName] est introuvable : $themePath"
);
}
2025-07-25 17:21:23 +02:00
if (!file_exists($configFile)) {
Log::error("Le fichier de config du thème [$themeName] est introuvable : $configFile");
throw new \Exception(
"Le fichier de config du thème [$themeName] est introuvable : $configFile"
);
}
2025-07-25 17:21:23 +02:00
return require $configFile;
});
}
} //end if