Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
feat: fix issues with env
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Oct 3, 2022
1 parent eefe39a commit 598aa89
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/Router/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Leaf Router [Core]
* ---------------
* Core module for leaf router
*
*
* @author Michael Darko
* @since 3.0
* @version 1.0
Expand Down Expand Up @@ -101,7 +101,7 @@ public static function configure(array $config)

/**
* Force call the Leaf URL handler
*
*
* @param string $method The method to call
* @param string $url The uri to force
*/
Expand All @@ -126,7 +126,7 @@ public static function routes(): array

/**
* Set a global namespace for your handlers
*
*
* @param string $namespace The global namespace to set
*/
public static function setNamespace(string $namespace)
Expand Down Expand Up @@ -180,15 +180,15 @@ protected static function mapHandler($handler, $options): array

/**
* Add a router hook
*
*
* Available hooks
* - router.before
* - router.before.route
* - router.before.dispatch
* - router.after.dispatch
* - router.after.route
* - router.after
*
*
* @param string $name The hook to set
* @param callable|null $handler The hook handler
*/
Expand All @@ -203,7 +203,7 @@ public static function hook(string $name, callable $handler)

/**
* Call a router hook
*
*
* @param string $name The hook to call
*/
private static function callHook(string $name)
Expand All @@ -213,7 +213,7 @@ private static function callHook(string $name)

/**
* Add a route specific middleware
*
*
* @param string $methods Allowed methods, separated by |
* @param string|array $path The path/route to apply middleware on
* @param callable $handler The middleware handler
Expand Down Expand Up @@ -305,7 +305,7 @@ public static function getCurrentUri(): string

/**
* Get route info of the current route
*
*
* @return array The route info array
*/
public static function getRoute(): array
Expand All @@ -323,20 +323,15 @@ public static function run(?callable $callback = null)
{
$config = static::$config;

$appenv = getenv();
$mode = $appenv['APP_ENV'] ?? null;
$debug = $appenv['APP_DEBUG'] ?? null;
$appDown = $appenv['APP_DOWN'] ?? null;

if (class_exists('Leaf\App')) {
$config = array_merge($config, [
'mode' => $mode !== null ? $mode : \Leaf\Config::get('mode'),
'app.down' => $appDown !== null ? $appDown : \Leaf\Config::get('app.down'),
'debug' => (($debug !== null) ? $debug : \Leaf\Config::get('debug')) ?? $mode !== 'production',
'mode' => \Leaf\Config::get('mode'),
'app.down' => \Leaf\Anchor::toBool(\Leaf\Config::get('app.down')),
'debug' => \Leaf\Anchor::toBool(\Leaf\Config::get('debug')) ?? \Leaf\Config::get('mode') !== 'production',
]);
}

if ($config['app.down'] == 'true') {
if ($config['app.down'] === true) {
if (!static::$downHandler) {
if (class_exists('Leaf\App')) {
static::$downHandler = function () {
Expand Down

0 comments on commit 598aa89

Please sign in to comment.