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
48acf1d2
Commit
48acf1d2
authored
Jul 06, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring Config class to use Arr. Removed unnecessary comments.
parent
3015f24e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
25 deletions
+8
-25
config.php
system/config.php
+8
-25
No files found.
system/config.php
View file @
48acf1d2
...
...
@@ -29,34 +29,25 @@ class Config {
*/
public
static
function
get
(
$key
,
$default
=
null
)
{
// -----------------------------------------------------
// If no dot is in the key, we will just return the
// entire configuration array.
// -----------------------------------------------------
// If no "dot" is present in the key, return the entire configuration array.
if
(
strpos
(
$key
,
'.'
)
===
false
)
{
static
::
load
(
$key
);
return
(
array_key_exists
(
$key
,
static
::
$items
))
?
static
::
$items
[
$key
]
:
$default
;
return
Arr
::
get
(
static
::
$items
,
$key
,
$default
)
;
}
list
(
$file
,
$key
)
=
static
::
parse
(
$key
);
static
::
load
(
$file
);
// -----------------------------------------------------
// If the file doesn't exist, return the default.
// -----------------------------------------------------
// Verify that the configuration file actually exists.
if
(
!
array_key_exists
(
$file
,
static
::
$items
))
{
return
$default
;
}
// -----------------------------------------------------
// Return the configuration item. If the item doesn't
// exist, the default value will be returned.
// -----------------------------------------------------
return
(
array_key_exists
(
$key
,
static
::
$items
[
$file
]))
?
static
::
$items
[
$file
][
$key
]
:
$default
;
return
Arr
::
get
(
static
::
$items
[
$file
],
$key
,
$default
);
}
/**
...
...
@@ -83,11 +74,9 @@ class Config {
*/
private
static
function
parse
(
$key
)
{
// -----------------------------------------------------
// The left side of the dot is the file name, while
// the right side of the dot is the item within that
// file being requested.
// -----------------------------------------------------
// The left side of the dot is the file name, while the right side of the dot
// is the item within that file being requested.
$segments
=
explode
(
'.'
,
$key
);
if
(
count
(
$segments
)
<
2
)
...
...
@@ -99,25 +88,19 @@ class Config {
}
/**
* Load all of the configuration items.
* Load all of the configuration items
from a file
.
*
* @param string $file
* @return void
*/
public
static
function
load
(
$file
)
{
// -----------------------------------------------------
// Bail out if already loaded or doesn't exist.
// -----------------------------------------------------
if
(
array_key_exists
(
$file
,
static
::
$items
)
or
!
file_exists
(
$path
=
APP_PATH
.
'config/'
.
$file
.
EXT
))
{
return
;
}
// -----------------------------------------------------
// Load the configuration array into the array of items.
// The items array is keyed by filename.
// -----------------------------------------------------
static
::
$items
[
$file
]
=
require
$path
;
}
...
...
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