Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

refactoring Configure::load() to load config files from plugins, test…

…s and config files added

Signed-off-by: Mark Story <mark@mark-story.com>
  • Loading branch information...
commit 7a4793a20c213159368e24cdbbebca94e9a871a0 1 parent e1d6036
@ceeram ceeram authored markstory committed
View
10 cake/libs/configure.php
@@ -201,8 +201,16 @@ function delete($var = null) {
*/
function load($fileName) {
$found = false;
+ $pluginPath = false;
+ if(strpos($fileName, '.') !== false) {
+ $plugin = explode('.', $fileName, 2);
+ $pluginPath = App::pluginPath($plugin[0]);
+ }
- if (file_exists(CONFIGS . $fileName . '.php')) {
+ if ($pluginPath && file_exists($pluginPath . 'config' . DS . $plugin[1] . '.php')) {
+ include($pluginPath . 'config' . DS . $plugin[1] . '.php');
+ $found = true;
+ } elseif (file_exists(CONFIGS . $fileName . '.php')) {
include(CONFIGS . $fileName . '.php');
$found = true;
} elseif (file_exists(CACHE . 'persistent' . DS . $fileName . '.php')) {
View
21 cake/tests/cases/libs/configure.test.php
@@ -225,6 +225,27 @@ function testLoad() {
}
/**
+ * testLoad method
+ *
+ * @access public
+ * @return void
+ */
+ function testLoadPlugin() {
+ App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true);
+ $result = Configure::load('test_plugin.load');
+ $this->assertTrue($result === null);
+ $expected = '/test_app/plugins/test_plugin/config/load.php';
+ $config = Configure::read('plugin_load');
+ $this->assertEqual($config, $expected);
+
+ $result = Configure::load('test_plugin.more.load');
+ $this->assertTrue($result === null);
+ $expected = '/test_app/plugins/test_plugin/config/more.load.php';
+ $config = Configure::read('plugin_more_load');
+ $this->assertEqual($config, $expected);
+ }
+
+/**
* testStore method
*
* @access public
View
3  cake/tests/test_app/plugins/test_plugin/config/load.php
@@ -0,0 +1,3 @@
+<?php
+$config['plugin_load'] = '/test_app/plugins/test_plugin/config/load.php';
+?>
View
3  cake/tests/test_app/plugins/test_plugin/config/more.load.php
@@ -0,0 +1,3 @@
+<?php
+$config['plugin_more_load'] = '/test_app/plugins/test_plugin/config/more.load.php';
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.