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
c81be6d2
Commit
c81be6d2
authored
Jan 30, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix config class bug.
parent
c44b6264
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
14 deletions
+36
-14
config.php
laravel/config.php
+36
-14
No files found.
laravel/config.php
View file @
c81be6d2
...
...
@@ -60,14 +60,6 @@ class Config {
*/
public
static
function
get
(
$key
)
{
// First, we'll check the keyed cache of configuration items, as this will
// be the fastest method of retrieving the configuration option. After an
// item is retrieved, it is always stored in the cache by its key.
if
(
array_key_exists
(
$key
,
static
::
$cache
))
{
return
static
::
$cache
[
$key
];
}
list
(
$bundle
,
$file
,
$item
)
=
static
::
parse
(
$key
);
if
(
!
static
::
load
(
$bundle
,
$file
))
return
;
...
...
@@ -77,9 +69,14 @@ class Config {
// If a specific configuration item was not requested, the key will be null,
// meaning we need to return the entire array of configuration item from the
// requested configuration file. Otherwise we can return the item.
$value
=
(
is_null
(
$item
))
?
$items
:
array_get
(
$items
,
$item
);
return
static
::
$cache
[
$key
]
=
$value
;
if
(
is_null
(
$item
))
{
return
$items
;
}
else
{
return
array_get
(
$items
,
$item
);
}
}
/**
...
...
@@ -102,7 +99,22 @@ class Config {
*/
public
static
function
set
(
$key
,
$value
)
{
static
::
$cache
[
$key
]
=
$value
;
list
(
$bundle
,
$file
,
$item
)
=
static
::
parse
(
$key
);
static
::
load
(
$bundle
,
$file
);
// If the item is null, it means the developer wishes to set the entire
// configuration array to a given value, so we will pass the entire
// array for the bundle into the array_set method, otherwise we'll
// only pass the file array for the bundle.
if
(
is_null
(
$item
))
{
array_set
(
static
::
$items
[
$bundle
],
$file
,
$value
);
}
else
{
array_set
(
static
::
$items
[
$bundle
][
$file
],
$item
,
$value
);
}
}
/**
...
...
@@ -115,6 +127,14 @@ class Config {
*/
protected
static
function
parse
(
$key
)
{
// First, we'll check the keyed cache of configuration items, as this will
// be the fastest method of retrieving the configuration option. After an
// item is parsed, it is always stored in the cache by its key.
if
(
array_key_exists
(
$key
,
static
::
$cache
))
{
return
static
::
$cache
[
$key
];
}
$bundle
=
Bundle
::
name
(
$key
);
$segments
=
explode
(
'.'
,
Bundle
::
element
(
$key
));
...
...
@@ -124,12 +144,14 @@ class Config {
// If that is the case, we'll make the item field of the array "null".
if
(
count
(
$segments
)
>=
2
)
{
return
array
(
$bundle
,
$segments
[
0
],
implode
(
'.'
,
array_slice
(
$segments
,
1
)));
$parsed
=
array
(
$bundle
,
$segments
[
0
],
implode
(
'.'
,
array_slice
(
$segments
,
1
)));
}
else
{
return
array
(
$bundle
,
$segments
[
0
],
null
);
$parsed
=
array
(
$bundle
,
$segments
[
0
],
null
);
}
return
static
::
$cache
[
$key
]
=
$parsed
;
}
/**
...
...
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