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
d9b7b7dc
Commit
d9b7b7dc
authored
Aug 15, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor the config class for more simplicity.
parent
cd90845a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
14 deletions
+6
-14
config.php
system/config.php
+6
-14
No files found.
system/config.php
View file @
d9b7b7dc
...
...
@@ -40,10 +40,7 @@ class Config {
{
list
(
$module
,
$file
,
$key
)
=
static
::
parse
(
$key
);
if
(
!
static
::
load
(
$module
,
$file
))
{
return
is_callable
(
$default
)
?
call_user_func
(
$default
)
:
$default
;
}
static
::
load
(
$module
,
$file
);
if
(
is_null
(
$key
))
return
static
::
$items
[
$module
][
$file
];
...
...
@@ -63,16 +60,13 @@ class Config {
{
list
(
$module
,
$file
,
$key
)
=
static
::
parse
(
$key
);
if
(
!
static
::
load
(
$module
,
$file
))
{
throw
new
\Exception
(
"Error setting configuration option. Option [
$key
] is not defined."
);
}
static
::
load
(
$module
,
$file
);
(
is_null
(
$key
))
?
static
::
$items
[
$module
][
$file
]
=
$value
:
Arr
::
set
(
static
::
$items
[
$module
][
$file
],
$key
,
$value
);
}
/**
* Parse a configuration key into its module, file, and key
par
ts.
* Parse a configuration key into its module, file, and key
segmen
ts.
*
* @param string $key
* @return array
...
...
@@ -96,11 +90,11 @@ class Config {
*
* @param string $file
* @param string $module
* @return
bool
* @return
void
*/
private
static
function
load
(
$module
,
$file
)
{
if
(
isset
(
static
::
$items
[
$module
]
)
and
array_key_exists
(
$file
,
static
::
$items
[
$modu
le
]))
return
true
;
if
(
isset
(
static
::
$items
[
$module
]
[
$fi
le
]))
return
true
;
$path
=
(
$module
===
'application'
)
?
CONFIG_PATH
:
MODULE_PATH
.
$module
.
'/config/'
;
...
...
@@ -114,9 +108,7 @@ class Config {
$config
=
array_merge
(
$config
,
require
$path
);
}
if
(
count
(
$config
)
>
0
)
static
::
$items
[
$module
][
$file
]
=
$config
;
return
isset
(
static
::
$items
[
$module
][
$file
]);
static
::
$items
[
$module
][
$file
]
=
$config
;
}
}
\ No newline at end of file
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