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
57922c5a
Commit
57922c5a
authored
Aug 14, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow Config::set to set an entire configuation array.
parent
9f1edfae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
4 deletions
+24
-4
config.php
system/config.php
+24
-4
No files found.
system/config.php
View file @
57922c5a
...
@@ -5,12 +5,14 @@ class Config {
...
@@ -5,12 +5,14 @@ class Config {
/**
/**
* All of the loaded configuration items.
* All of the loaded configuration items.
*
*
* The configuration item arrays are keyed by module and file.
*
* @var array
* @var array
*/
*/
public
static
$items
=
array
();
public
static
$items
=
array
();
/**
/**
* Determine if a configuration
item or file
exists.
* Determine if a configuration
file or item
exists.
*
*
* @param string $key
* @param string $key
* @return bool
* @return bool
...
@@ -30,6 +32,14 @@ class Config {
...
@@ -30,6 +32,14 @@ class Config {
* If the name of a configuration file is passed without specifying an item, the
* If the name of a configuration file is passed without specifying an item, the
* entire configuration array will be returned.
* entire configuration array will be returned.
*
*
* <code>
* // Get the application timezone
* $timezone = Config::get('application.timezone');
*
* // Get the application configuration array
* $application = Config::get('application');
* </code>
*
* @param string $key
* @param string $key
* @param string $default
* @param string $default
* @return array
* @return array
...
@@ -51,6 +61,16 @@ class Config {
...
@@ -51,6 +61,16 @@ class Config {
/**
/**
* Set a configuration item.
* Set a configuration item.
*
*
* If a configuration item is not specified, the entire configuration array will be set.
*
* <code>
* // Set the application timezone
* Config::set('application.timezone', 'America/Chicago');
*
* // Set the application configuration array
* Config::set('application', array());
* </code>
*
* @param string $key
* @param string $key
* @param mixed $value
* @param mixed $value
* @return void
* @return void
...
@@ -59,16 +79,16 @@ class Config {
...
@@ -59,16 +79,16 @@ class Config {
{
{
list
(
$module
,
$file
,
$key
)
=
static
::
parse
(
$key
);
list
(
$module
,
$file
,
$key
)
=
static
::
parse
(
$key
);
if
(
is_null
(
$key
)
or
!
static
::
load
(
$module
,
$file
))
if
(
!
static
::
load
(
$module
,
$file
))
{
{
throw
new
\Exception
(
"Error setting configuration option. Option [
$key
] is not defined."
);
throw
new
\Exception
(
"Error setting configuration option. Option [
$key
] is not defined."
);
}
}
static
::
$items
[
$module
][
$file
][
$key
]
=
$value
;
(
is_null
(
$key
))
?
static
::
$items
[
$module
][
$file
]
=
$value
:
static
::
$items
[
$module
][
$file
][
$key
]
=
$value
;
}
}
/**
/**
* Parse a configuration key.
* Parse a configuration key
into its module, file, and key segments
.
*
*
* @param string $key
* @param string $key
* @return array
* @return array
...
...
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