Aggiornato Composer

This commit is contained in:
Paolo A
2024-05-17 12:24:19 +00:00
parent 4ac62108b5
commit ec201d75b2
2238 changed files with 38684 additions and 59785 deletions

View File

@@ -24,6 +24,22 @@ use Throwable;
class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
/** @var callable|null */
protected $appGetter = null;
/** @var callable|null */
protected $localeGetter = null;
public function setAppGetter(?callable $appGetter): void
{
$this->appGetter = $appGetter;
}
public function setLocaleGetter(?callable $localeGetter): void
{
$this->localeGetter = $localeGetter;
}
public function boot()
{
$this->updateLocale();
@@ -44,8 +60,12 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider
public function updateLocale()
{
$app = $this->app && method_exists($this->app, 'getLocale') ? $this->app : app('translator');
$locale = $app->getLocale();
$locale = $this->getLocale();
if ($locale === null) {
return;
}
Carbon::setLocale($locale);
CarbonImmutable::setLocale($locale);
CarbonPeriod::setLocale($locale);
@@ -70,6 +90,34 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider
// Needed for Laravel < 5.3 compatibility
}
protected function getLocale()
{
if ($this->localeGetter) {
return ($this->localeGetter)();
}
$app = $this->getApp();
$app = $app && method_exists($app, 'getLocale')
? $app
: $this->getGlobalApp('translator');
return $app ? $app->getLocale() : null;
}
protected function getApp()
{
if ($this->appGetter) {
return ($this->appGetter)();
}
return $this->app ?? $this->getGlobalApp();
}
protected function getGlobalApp(...$args)
{
return \function_exists('app') ? \app(...$args) : null;
}
protected function isEventDispatcher($instance)
{
return $instance instanceof EventDispatcher