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
9018d6cc
Commit
9018d6cc
authored
Aug 08, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring the Config class.
parent
fe39d507
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
18 deletions
+6
-18
config.php
system/config.php
+6
-18
No files found.
system/config.php
View file @
9018d6cc
...
@@ -38,15 +38,11 @@ class Config {
...
@@ -38,15 +38,11 @@ class Config {
{
{
list
(
$module
,
$file
,
$key
)
=
static
::
parse
(
$key
);
list
(
$module
,
$file
,
$key
)
=
static
::
parse
(
$key
);
if
(
!
static
::
load
(
$module
,
$file
))
// If the configuration file doesn't exist, return the default value.
{
if
(
!
static
::
load
(
$module
,
$file
))
return
is_callable
(
$default
)
?
call_user_func
(
$default
)
:
$default
;
return
is_callable
(
$default
)
?
call_user_func
(
$default
)
:
$default
;
}
if
(
is_null
(
$key
))
// If no key was specified, return the entire configuration array.
{
if
(
is_null
(
$key
))
return
static
::
$items
[
$module
][
$file
];
return
static
::
$items
[
$module
][
$file
];
}
return
Arr
::
get
(
static
::
$items
[
$module
][
$file
],
$key
,
$default
);
return
Arr
::
get
(
static
::
$items
[
$module
][
$file
],
$key
,
$default
);
}
}
...
@@ -81,14 +77,9 @@ class Config {
...
@@ -81,14 +77,9 @@ class Config {
*/
*/
private
static
function
parse
(
$key
)
private
static
function
parse
(
$key
)
{
{
// Check for a module qualifier. If a module name is present, we need to extract it from
// the configuration key, otherwise, we will use "application" as the module.
$module
=
(
strpos
(
$key
,
'::'
)
!==
false
)
?
substr
(
$key
,
0
,
strpos
(
$key
,
':'
))
:
'application'
;
$module
=
(
strpos
(
$key
,
'::'
)
!==
false
)
?
substr
(
$key
,
0
,
strpos
(
$key
,
':'
))
:
'application'
;
if
(
$module
!=
'application'
)
if
(
$module
!==
'application'
)
$key
=
substr
(
$key
,
strpos
(
$key
,
':'
)
+
2
);
{
$key
=
substr
(
$key
,
strpos
(
$key
,
':'
)
+
2
);
}
$segments
=
explode
(
'.'
,
$key
);
$segments
=
explode
(
'.'
,
$key
);
...
@@ -122,10 +113,7 @@ class Config {
...
@@ -122,10 +113,7 @@ class Config {
$config
=
array_merge
(
$config
,
require
$path
);
$config
=
array_merge
(
$config
,
require
$path
);
}
}
if
(
count
(
$config
)
>
0
)
if
(
count
(
$config
)
>
0
)
static
::
$items
[
$module
][
$file
]
=
$config
;
{
static
::
$items
[
$module
][
$file
]
=
$config
;
}
return
isset
(
static
::
$items
[
$module
][
$file
]);
return
isset
(
static
::
$items
[
$module
][
$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