Skip to content

Commit

Permalink
Support Laravel < 6 for Illuminate\Support\Env usage (#750)
Browse files Browse the repository at this point in the history
* Use Env::get instead of env

It conflicts with other `env()` global functions (such as CakePHP), and most of them don't handle closures.

* Support Laravel < 6 for Illuminate\Support\Env usage

Fixed `env()` and `Illuminate\Support\Env` usage to support Laravel < 6
  • Loading branch information
oytuntez authored Oct 1, 2020
1 parent 9191396 commit 4f0bfd8
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/Mcamara/LaravelLocalization/LaravelLocalization.php
Original file line number Diff line number Diff line change
Expand Up @@ -1037,12 +1037,22 @@ protected function normalizeAttributes($attributes)
*/
protected function getForcedLocale()
{
return Env::get(static::ENV_ROUTE_KEY, function () {
$value = getenv(static::ENV_ROUTE_KEY);
if (version_compare($this->app->version(), '6') >= 0) {
return Env::get(static::ENV_ROUTE_KEY, function () {
$value = getenv(static::ENV_ROUTE_KEY);

if ($value !== false) {
return $value;
}
});
if ($value !== false) {
return $value;
}
});
} else {
return env(static::ENV_ROUTE_KEY, function () {
$value = getenv(static::ENV_ROUTE_KEY);

if ($value !== false) {
return $value;
}
});
}
}
}

0 comments on commit 4f0bfd8

Please sign in to comment.