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
5a4e6ebc
Commit
5a4e6ebc
authored
Jun 17, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved comments in config class.
parent
e467c831
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
config.php
system/config.php
+18
-18
No files found.
system/config.php
View file @
5a4e6ebc
...
@@ -17,17 +17,16 @@ class Config {
...
@@ -17,17 +17,16 @@ class Config {
*/
*/
public
static
function
get
(
$key
)
public
static
function
get
(
$key
)
{
{
// -----------------------------------------------------
// Parse the key to separate the file and key name.
// -----------------------------------------------------
list
(
$file
,
$key
)
=
static
::
parse
(
$key
);
list
(
$file
,
$key
)
=
static
::
parse
(
$key
);
// -----------------------------------------------------
// Load the appropriate configuration file.
// -----------------------------------------------------
static
::
load
(
$file
);
static
::
load
(
$file
);
return
(
array_key_exists
(
$key
,
static
::
$items
[
$file
]))
?
static
::
$items
[
$file
][
$key
]
:
null
;
if
(
array_key_exists
(
$key
,
static
::
$items
[
$file
]))
{
return
static
::
$items
[
$file
][
$key
];
}
throw
new
\Exception
(
"Configuration item [
$key
] is not defined."
);
}
}
/**
/**
...
@@ -39,14 +38,8 @@ class Config {
...
@@ -39,14 +38,8 @@ class Config {
*/
*/
public
static
function
set
(
$key
,
$value
)
public
static
function
set
(
$key
,
$value
)
{
{
// -----------------------------------------------------
// Parse the key to separate the file and key name.
// -----------------------------------------------------
list
(
$file
,
$key
)
=
static
::
parse
(
$key
);
list
(
$file
,
$key
)
=
static
::
parse
(
$key
);
// -----------------------------------------------------
// Load the appropriate configuration file.
// -----------------------------------------------------
static
::
load
(
$file
);
static
::
load
(
$file
);
static
::
$items
[
$file
][
$key
]
=
$value
;
static
::
$items
[
$file
][
$key
]
=
$value
;
...
@@ -60,6 +53,14 @@ class Config {
...
@@ -60,6 +53,14 @@ class Config {
*/
*/
private
static
function
parse
(
$key
)
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.
//
// This syntax allows for the easy retrieval and setting
// of configuration items.
// -----------------------------------------------------
$segments
=
explode
(
'.'
,
$key
);
$segments
=
explode
(
'.'
,
$key
);
if
(
count
(
$segments
)
<
2
)
if
(
count
(
$segments
)
<
2
)
...
@@ -67,11 +68,6 @@ class Config {
...
@@ -67,11 +68,6 @@ class Config {
throw
new
\Exception
(
"Invalid configuration key [
$key
]."
);
throw
new
\Exception
(
"Invalid configuration key [
$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.
// -----------------------------------------------------
return
array
(
$segments
[
0
],
implode
(
'.'
,
array_slice
(
$segments
,
1
)));
return
array
(
$segments
[
0
],
implode
(
'.'
,
array_slice
(
$segments
,
1
)));
}
}
...
@@ -96,6 +92,10 @@ class Config {
...
@@ -96,6 +92,10 @@ class Config {
throw
new
\Exception
(
"Configuration file [
$file
] does not exist."
);
throw
new
\Exception
(
"Configuration file [
$file
] does not exist."
);
}
}
// -----------------------------------------------------
// Load the configuration array into the array of items.
// The items array is keyed by filename.
// -----------------------------------------------------
static
::
$items
[
$file
]
=
require
$path
;
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