Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
5d52da69
Commit
5d52da69
authored
Apr 14, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use injection on the request::detect_env method for better testability.
parent
44dbbe01
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
core.php
laravel/core.php
+3
-1
request.php
laravel/request.php
+3
-4
No files found.
laravel/core.php
View file @
5d52da69
...
@@ -168,7 +168,9 @@ if (Request::cli())
...
@@ -168,7 +168,9 @@ if (Request::cli())
}
}
else
else
{
{
$environment
=
Request
::
detect_env
(
$environments
);
$root
=
Request
::
foundation
()
->
getRootUrl
();
$environment
=
Request
::
detect_env
(
$environments
,
$root
);
}
}
/*
/*
...
...
laravel/request.php
View file @
5d52da69
...
@@ -212,12 +212,11 @@ class Request {
...
@@ -212,12 +212,11 @@ class Request {
* Detect the current environment from an environment configuration.
* Detect the current environment from an environment configuration.
*
*
* @param array $environments
* @param array $environments
* @param string $uri
* @return string|null
* @return string|null
*/
*/
public
static
function
detect_env
(
array
$environments
)
public
static
function
detect_env
(
array
$environments
,
$uri
)
{
{
$root
=
static
::
foundation
()
->
getRootUrl
();
foreach
(
$environments
as
$environment
=>
$patterns
)
foreach
(
$environments
as
$environment
=>
$patterns
)
{
{
// Essentially we just want to loop through each environment pattern
// Essentially we just want to loop through each environment pattern
...
@@ -225,7 +224,7 @@ class Request {
...
@@ -225,7 +224,7 @@ class Request {
// we'll simply return the environment for that URI pattern.
// we'll simply return the environment for that URI pattern.
foreach
(
$patterns
as
$pattern
)
foreach
(
$patterns
as
$pattern
)
{
{
if
(
Str
::
is
(
$pattern
,
$
root
))
if
(
Str
::
is
(
$pattern
,
$
uri
))
{
{
return
$environment
;
return
$environment
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment