diff --git a/php/src/app/app.php b/php/src/app/app.php index e7cb4c7..13aa994 100644 --- a/php/src/app/app.php +++ b/php/src/app/app.php @@ -9,6 +9,7 @@ use nulib\ExitError; use nulib\os\path; use nulib\os\sh; use nulib\php\func; +use nulib\ref\ref_profiles; use nulib\str; use nulib\ValueException; @@ -114,13 +115,21 @@ class app { static function get_profile(?bool &$productionMode=null): string { return self::get()->getProfile($productionMode); } + + static function is_production_mode(): bool { + return self::get()->isProductionMode(); + } static function is_prod(): bool { - return self::get_profile() === "prod"; + return self::get_profile() === ref_profiles::PROD; + } + + static function is_test(): bool { + return self::get_profile() === ref_profiles::TEST; } static function is_devel(): bool { - return self::get_profile() === "devel"; + return self::get_profile() === ref_profiles::DEVEL; } static function set_profile(?string $profile=null, ?bool $productionMode=null): void { diff --git a/php/src/app/cli/Application.php b/php/src/app/cli/Application.php index 330efdf..02f0901 100644 --- a/php/src/app/cli/Application.php +++ b/php/src/app/cli/Application.php @@ -14,6 +14,7 @@ use nulib\output\console; use nulib\output\log; use nulib\output\msg; use nulib\output\std\StdMessenger; +use nulib\ref\ref_profiles; /** * Class Application: application de base @@ -257,9 +258,9 @@ EOT); "action" => [app::class, "set_profile"], "help" => "spécifier le profil d'exécution", ], - ["-P", "--prod", "action" => [app::class, "set_profile", "prod"]], - ["-T", "--test", "action" => [app::class, "set_profile", "test"]], - ["--devel", "action" => [app::class, "set_profile", "devel"]], + ["-P", "--prod", "action" => [app::class, "set_profile", ref_profiles::PROD]], + ["-T", "--test", "action" => [app::class, "set_profile", ref_profiles::TEST]], + ["--devel", "action" => [app::class, "set_profile", ref_profiles::DEVEL]], ], ]; @@ -307,9 +308,9 @@ EOT); } const PROFILE_COLORS = [ - "prod" => "@r", - "test" => "@g", - "devel" => "@w", + ref_profiles::PROD => "@r", + ref_profiles::TEST => "@g", + ref_profiles::DEVEL => "@w", ]; const DEFAULT_PROFILE_COLOR = "y"; diff --git a/php/src/app/config/ProfileManager.php b/php/src/app/config/ProfileManager.php index 6645906..9e66c5b 100644 --- a/php/src/app/config/ProfileManager.php +++ b/php/src/app/config/ProfileManager.php @@ -3,6 +3,7 @@ namespace nulib\app\config; use nulib\app\app; use nulib\app\config; +use nulib\ref\ref_profiles; /** * Class ProfileManager: gestionnaire de profils @@ -21,10 +22,7 @@ class ProfileManager { const PROFILES = null; /** @var array profils dont le mode production doit être actif */ - const PRODUCTION_MODES = [ - "prod" => true, - "test" => true, - ]; + const PRODUCTION_MODES = ref_profiles::PRODUCTION_MODES; /** * @var array mapping profil d'application --> profil effectif @@ -114,7 +112,7 @@ class ProfileManager { $profile ??= $this->getConfigProfile(); $profile ??= $this->getDefaultProfile(); if ($this->isAppProfile) { - $profile ??= $this->profiles[0] ?? "prod"; + $profile ??= $this->profiles[0] ?? ref_profiles::PROD; } else { $profile ??= $this->mapProfile(app::get_profile()); } diff --git a/php/src/file/Stream.php b/php/src/file/Stream.php index c1d7496..89b3c7c 100644 --- a/php/src/file/Stream.php +++ b/php/src/file/Stream.php @@ -6,7 +6,7 @@ use nulib\NoMoreDataException; use nulib\os\EOFException; use nulib\os\IOException; use nulib\php\iter\AbstractIterator; -use nulib\ref\file\csv\ref_csv; +use nulib\ref\ref_csv; use nulib\str; use nulib\ValueException; diff --git a/php/src/file/csv/csv_flavours.php b/php/src/file/csv/csv_flavours.php index 4bc7bd9..2a782e6 100644 --- a/php/src/file/csv/csv_flavours.php +++ b/php/src/file/csv/csv_flavours.php @@ -2,7 +2,7 @@ namespace nulib\file\csv; use nulib\cl; -use nulib\ref\file\csv\ref_csv; +use nulib\ref\ref_csv; use nulib\str; class csv_flavours { diff --git a/php/src/ref/ref_cache.php b/php/src/ref/ref_cache.php new file mode 100644 index 0000000..d1dbf0a --- /dev/null +++ b/php/src/ref/ref_cache.php @@ -0,0 +1,11 @@ + + + true, + self::TEST => true, + ]; +}