Skip to content

Commit 6640df4

Browse files
committed
feat: add Services::superglobals()
1 parent bd91a49 commit 6640df4

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

system/Config/BaseService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
* @method static Security security(App $config = null, $getShared = true)
127127
* @method static Session session(App $config = null, $getShared = true)
128128
* @method static SiteURIFactory siteurifactory(App $config = null, Superglobals $superglobals = null, $getShared = true)
129+
* @method static Superglobals superglobals(array $server = null, array $get = null, bool $getShared = true)
129130
* @method static Throttler throttler($getShared = true)
130131
* @method static Timer timer($getShared = true)
131132
* @method static Toolbar toolbar(ConfigToolbar $config = null, $getShared = true)

system/Config/Services.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,11 +717,28 @@ public static function siteurifactory(
717717
}
718718

719719
$config ??= config('App');
720-
$superglobals ??= new Superglobals();
720+
$superglobals ??= AppServices::superglobals();
721721

722722
return new SiteURIFactory($config, $superglobals);
723723
}
724724

725+
/**
726+
* Superglobals.
727+
*
728+
* @return Superglobals
729+
*/
730+
public static function superglobals(
731+
?array $server = null,
732+
?array $get = null,
733+
bool $getShared = true
734+
) {
735+
if ($getShared) {
736+
return static::getSharedInstance('superglobals', $server, $get);
737+
}
738+
739+
return new Superglobals($server, $get);
740+
}
741+
725742
/**
726743
* The Throttler class provides a simple method for implementing
727744
* rate limiting in your applications.
@@ -783,7 +800,7 @@ public static function uri(?string $uri = null, bool $getShared = true)
783800

784801
if ($uri === null) {
785802
$appConfig = config(App::class);
786-
$factory = AppServices::siteurifactory($appConfig, new Superglobals());
803+
$factory = AppServices::siteurifactory($appConfig, AppServices::superglobals());
787804

788805
return $factory->createFromGlobals();
789806
}

0 commit comments

Comments
 (0)