Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
298
Merge Requests
298
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
d2f1b256
Commit
d2f1b256
authored
Mar 23, 2012
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#1484690
by Pol, jhedstrom, beejeebus: implement overrides in the configuration system.
parent
5868d523
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
3 deletions
+53
-3
core/lib/Drupal/Core/Config/DrupalConfig.php
core/lib/Drupal/Core/Config/DrupalConfig.php
+13
-3
core/lib/Drupal/Core/Config/DrupalConfigVerifiedStorage.php
core/lib/Drupal/Core/Config/DrupalConfigVerifiedStorage.php
+7
-0
core/lib/Drupal/Core/Config/DrupalConfigVerifiedStorageInterface.php
...upal/Core/Config/DrupalConfigVerifiedStorageInterface.php
+5
-0
core/modules/config/config.test
core/modules/config/config.test
+28
-0
No files found.
core/lib/Drupal/Core/Config/DrupalConfig.php
View file @
d2f1b256
...
...
@@ -81,17 +81,27 @@ public function isOverridden($key) {
* The data that was requested.
*/
public
function
get
(
$key
=
''
)
{
global
$conf
;
$name
=
$this
->
_verifiedStorage
->
getName
();
if
(
isset
(
$conf
[
$name
]))
{
$merged_data
=
drupal_array_merge_deep
(
$this
->
data
,
$conf
[
$name
]);
}
else
{
$merged_data
=
$this
->
data
;
}
if
(
empty
(
$key
))
{
return
$
this
->
data
;
return
$
merged_
data
;
}
else
{
$parts
=
explode
(
'.'
,
$key
);
if
(
count
(
$parts
)
==
1
)
{
return
isset
(
$
this
->
data
[
$key
])
?
$this
->
data
[
$key
]
:
NULL
;
return
isset
(
$
merged_data
[
$key
])
?
$merged_
data
[
$key
]
:
NULL
;
}
else
{
$key_exists
=
NULL
;
$value
=
drupal_array_get_nested_value
(
$
this
->
data
,
$parts
,
$key_exists
);
$value
=
drupal_array_get_nested_value
(
$
merged_
data
,
$parts
,
$key_exists
);
return
$key_exists
?
$value
:
NULL
;
}
}
...
...
core/lib/Drupal/Core/Config/DrupalConfigVerifiedStorage.php
View file @
d2f1b256
...
...
@@ -99,4 +99,11 @@ public function delete() {
$this
->
deleteFromActive
();
$this
->
deleteFile
();
}
/**
* Implements DrupalConfigVerifiedStorageInterface::getName().
*/
public
function
getName
()
{
return
$this
->
name
;
}
}
core/lib/Drupal/Core/Config/DrupalConfigVerifiedStorageInterface.php
View file @
d2f1b256
...
...
@@ -81,4 +81,9 @@ function writeToFile($data);
* @todo
*/
static
function
getNamesWithPrefix
(
$prefix
);
/**
* Gets the name of this object.
*/
public
function
getName
();
}
core/modules/config/config.test
View file @
d2f1b256
...
...
@@ -268,3 +268,31 @@ class ConfigFileContentTestCase extends DrupalWebTestCase {
// Attempt to delete non-existing configuration.
}
}
/**
* Tests configuration overriding from settings.php.
*/
class
ConfOverrideTestCase
extends
DrupalWebTestCase
{
protected
$testContent
=
'Good morning, Denver!'
;
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Configuration overrides'
,
'description'
=>
'Tests configuration overrides through settings.php.'
,
'group'
=>
'Configuration'
,
);
}
/**
* Test configuration override.
*/
function
testConfigurationOverride
()
{
global
$conf
;
$config
=
config
(
'system.performance'
);
$this
->
assertNotEqual
(
$config
->
get
(
'cache'
),
$this
->
testContent
);
$conf
[
'system.performance'
][
'cache'
]
=
$this
->
testContent
;
$config
=
config
(
'system.performance'
);
$this
->
assertEqual
(
$config
->
get
(
'cache'
),
$conf
[
'system.performance'
][
'cache'
]);
}
}
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