Skip to content

Commit ac7948a

Browse files
count on app/Config/Services
Use \Config\Services instead of \CodeIgniter\Config\Services
1 parent 3919bc3 commit ac7948a

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

system/Helpers/url_helper.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function base_url($uri = '', string $protocol = null): string
111111
// We should be using the configured baseURL that the user set;
112112
// otherwise get rid of the path, because we have
113113
// no way of knowing the intent...
114-
$config = \CodeIgniter\Config\Services::request()->config;
114+
$config = \Config\Services::request()->config;
115115

116116
// If baseUrl does not have a trailing slash it won't resolve
117117
// correctly for users hosting in a subfolder.
@@ -130,7 +130,7 @@ function base_url($uri = '', string $protocol = null): string
130130

131131
// If the scheme wasn't provided, check to
132132
// see if it was a secure request
133-
if (empty($protocol) && \CodeIgniter\Config\Services::request()->isSecure())
133+
if (empty($protocol) && \Config\Services::request()->isSecure())
134134
{
135135
$protocol = 'https';
136136
}
@@ -160,25 +160,21 @@ function base_url($uri = '', string $protocol = null): string
160160
*/
161161
function current_url(bool $returnObject = false)
162162
{
163-
$uri = clone service('request')->uri;
163+
$uri = clone \Config\Services::request()->uri;
164164

165165
// If hosted in a sub-folder, we will have additional
166166
// segments that show up prior to the URI path we just
167167
// grabbed from the request, so add it on if necessary.
168-
$baseUri = new \CodeIgniter\HTTP\URI(config('App')->baseURL);
168+
$baseUri = new \CodeIgniter\HTTP\URI(config(\Config\App::class)->baseURL);
169169

170170
if (! empty($baseUri->getPath()))
171171
{
172-
$path = rtrim($baseUri->getPath(), '/ ') . '/' . $uri->getPath();
173-
174-
$uri->setPath($path);
172+
$uri->setPath(rtrim($baseUri->getPath(), '/ ') . '/' . $uri->getPath());
175173
}
176174

177175
// Since we're basing off of the IncomingRequest URI,
178176
// we are guaranteed to have a host based on our own configs.
179-
return $returnObject
180-
? $uri
181-
: (string)$uri->setQuery('');
177+
return $returnObject ? $uri : (string) $uri->setQuery('');
182178
}
183179
}
184180

@@ -201,7 +197,7 @@ function previous_url(bool $returnObject = false)
201197
// Grab from the session first, if we have it,
202198
// since it's more reliable and safer.
203199
// Otherwise, grab a sanitized version from $_SERVER.
204-
$referer = $_SESSION['_ci_previous_url'] ?? \CodeIgniter\Config\Services::request()->getServer('HTTP_REFERER', FILTER_SANITIZE_URL);
200+
$referer = $_SESSION['_ci_previous_url'] ?? \Config\Services::request()->getServer('HTTP_REFERER', FILTER_SANITIZE_URL);
205201

206202
$referer = $referer ?? site_url('/');
207203

@@ -222,7 +218,7 @@ function previous_url(bool $returnObject = false)
222218
*/
223219
function uri_string(): string
224220
{
225-
return \CodeIgniter\Config\Services::request()->uri->getPath();
221+
return \Config\Services::request()->uri->getPath();
226222
}
227223
}
228224

0 commit comments

Comments
 (0)