use injection on the request::detect_env method for better testability.
This commit is contained in:
@@ -168,7 +168,9 @@ if (Request::cli())
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$environment = Request::detect_env($environments);
|
$root = Request::foundation()->getRootUrl();
|
||||||
|
|
||||||
|
$environment = Request::detect_env($environments, $root);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -212,12 +212,11 @@ class Request {
|
|||||||
* Detect the current environment from an environment configuration.
|
* Detect the current environment from an environment configuration.
|
||||||
*
|
*
|
||||||
* @param array $environments
|
* @param array $environments
|
||||||
|
* @param string $uri
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function detect_env(array $environments)
|
public static function detect_env(array $environments, $uri)
|
||||||
{
|
{
|
||||||
$root = static::foundation()->getRootUrl();
|
|
||||||
|
|
||||||
foreach ($environments as $environment => $patterns)
|
foreach ($environments as $environment => $patterns)
|
||||||
{
|
{
|
||||||
// Essentially we just want to loop through each environment pattern
|
// Essentially we just want to loop through each environment pattern
|
||||||
@@ -225,7 +224,7 @@ class Request {
|
|||||||
// we'll simply return the environment for that URI pattern.
|
// we'll simply return the environment for that URI pattern.
|
||||||
foreach ($patterns as $pattern)
|
foreach ($patterns as $pattern)
|
||||||
{
|
{
|
||||||
if (Str::is($pattern, $root))
|
if (Str::is($pattern, $uri))
|
||||||
{
|
{
|
||||||
return $environment;
|
return $environment;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user