diff --git a/src/app/ProfileManager.php b/src/app/ProfileManager.php new file mode 100644 index 0000000..eae9822 --- /dev/null +++ b/src/app/ProfileManager.php @@ -0,0 +1,50 @@ + true, + "test" => true, + ]; + const PROFILE_MAP = null; + + function __construct(?array $params=null) { + $name = $params["name"] ?? static::NAME; + if ($name !== null) $name .= "_"; + $prefixes = [strtoupper($name)]; + $app = $params["app"] ?? false; + if ($app) $prefixes[] = "APP_"; + $this->envPrefixes = $prefixes; + } + + protected array $envPrefixes; + + function getEnvProfile(): ?string { + foreach ($this->envPrefixes as $prefix) { + $profile = getenv($prefix."PROFILE"); + if ($profile !== false) return $profile; + } + return null; + } + + protected ?string $defaultProfile = null; + + function getDefaultProfile(): ?string { + return $this->defaultProfile; + } + + function setDefaultProfile(?string $profile): void { + $this->defaultProfile = $profile; + } + + function getProfile(?bool &$productionMode=null): string { + } + + function setProfile(?string $profile=null, ?bool $productionMode=null): void { + } +} diff --git a/src/app/app.php b/src/app/app.php index 9592582..1fde156 100644 --- a/src/app/app.php +++ b/src/app/app.php @@ -386,7 +386,7 @@ class app { "etcdir" => $this->etcdir, "vardir" => $this->vardir, "logdir" => $this->logdir, - "profile" => $this->profile, + "profile" => $this->le, "appgroup" => $this->appgroup, "name" => $this->name, "title" => $this->title, diff --git a/src/app/config.php b/src/app/config.php new file mode 100644 index 0000000..9713d28 --- /dev/null +++ b/src/app/config.php @@ -0,0 +1,8 @@ +