Skip to content

Commit 9ec7fbc

Browse files
committed
feat: add Services::superglobals()
1 parent a4ba66d commit 9ec7fbc

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

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
@@ -710,11 +710,28 @@ public static function siteurifactory(
710710
}
711711

712712
$config ??= config('App');
713-
$superglobals ??= new Superglobals();
713+
$superglobals ??= AppServices::superglobals();
714714

715715
return new SiteURIFactory($config, $superglobals);
716716
}
717717

718+
/**
719+
* Superglobals.
720+
*
721+
* @return Superglobals
722+
*/
723+
public static function superglobals(
724+
?array $server = null,
725+
?array $get = null,
726+
bool $getShared = true
727+
) {
728+
if ($getShared) {
729+
return static::getSharedInstance('superglobals', $server, $get);
730+
}
731+
732+
return new Superglobals($server, $get);
733+
}
734+
718735
/**
719736
* The Throttler class provides a simple method for implementing
720737
* rate limiting in your applications.
@@ -776,7 +793,7 @@ public static function uri(?string $uri = null, bool $getShared = true)
776793

777794
if ($uri === null) {
778795
$appConfig = config(App::class);
779-
$factory = AppServices::siteurifactory($appConfig, new Superglobals());
796+
$factory = AppServices::siteurifactory($appConfig, AppServices::superglobals());
780797

781798
return $factory->createFromGlobals();
782799
}

0 commit comments

Comments
 (0)