diff --git a/system/Helpers/number_helper.php b/system/Helpers/number_helper.php index f53519804d83..cc9e925cba8a 100644 --- a/system/Helpers/number_helper.php +++ b/system/Helpers/number_helper.php @@ -214,7 +214,7 @@ function number_to_currency(float $num, string $currency, string $locale = null, function format_number(float $num, int $precision = 1, string $locale = null, array $options = []): string { // Locale is either passed in here, negotiated with client, or grabbed from our config file. - $locale = $locale ?? \CodeIgniter\Config\Services::request()->getLocale(); + $locale = $locale ?? \Config\Services::request()->getLocale(); // Type can be any of the NumberFormatter options, but provide a default. $type = (int) ($options['type'] ?? NumberFormatter::DECIMAL); diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index b05dd072be89..e39ed277003c 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -111,7 +111,7 @@ function base_url($uri = '', string $protocol = null): string // We should be using the configured baseURL that the user set; // otherwise get rid of the path, because we have // no way of knowing the intent... - $config = \CodeIgniter\Config\Services::request()->config; + $config = \Config\Services::request()->config; // If baseUrl does not have a trailing slash it won't resolve // correctly for users hosting in a subfolder. @@ -130,7 +130,7 @@ function base_url($uri = '', string $protocol = null): string // If the scheme wasn't provided, check to // see if it was a secure request - if (empty($protocol) && \CodeIgniter\Config\Services::request()->isSecure()) + if (empty($protocol) && \Config\Services::request()->isSecure()) { $protocol = 'https'; } @@ -160,25 +160,21 @@ function base_url($uri = '', string $protocol = null): string */ function current_url(bool $returnObject = false) { - $uri = clone service('request')->uri; + $uri = clone \Config\Services::request()->uri; // If hosted in a sub-folder, we will have additional // segments that show up prior to the URI path we just // grabbed from the request, so add it on if necessary. - $baseUri = new \CodeIgniter\HTTP\URI(config('App')->baseURL); + $baseUri = new \CodeIgniter\HTTP\URI(config(\Config\App::class)->baseURL); if (! empty($baseUri->getPath())) { - $path = rtrim($baseUri->getPath(), '/ ') . '/' . $uri->getPath(); - - $uri->setPath($path); + $uri->setPath(rtrim($baseUri->getPath(), '/ ') . '/' . $uri->getPath()); } // Since we're basing off of the IncomingRequest URI, // we are guaranteed to have a host based on our own configs. - return $returnObject - ? $uri - : (string)$uri->setQuery(''); + return $returnObject ? $uri : (string) $uri->setQuery(''); } } @@ -201,7 +197,7 @@ function previous_url(bool $returnObject = false) // Grab from the session first, if we have it, // since it's more reliable and safer. // Otherwise, grab a sanitized version from $_SERVER. - $referer = $_SESSION['_ci_previous_url'] ?? \CodeIgniter\Config\Services::request()->getServer('HTTP_REFERER', FILTER_SANITIZE_URL); + $referer = $_SESSION['_ci_previous_url'] ?? \Config\Services::request()->getServer('HTTP_REFERER', FILTER_SANITIZE_URL); $referer = $referer ?? site_url('/'); @@ -222,7 +218,7 @@ function previous_url(bool $returnObject = false) */ function uri_string(): string { - return \CodeIgniter\Config\Services::request()->uri->getPath(); + return \Config\Services::request()->uri->getPath(); } }