mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
refactoring Configure::load() to load config files from plugins, tests and config files added
Signed-off-by: Mark Story <mark@mark-story.com>
This commit is contained in:
parent
e1d60368f6
commit
7a4793a20c
4 changed files with 36 additions and 1 deletions
|
@ -201,8 +201,16 @@ class Configure extends Object {
|
|||
*/
|
||||
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')) {
|
||||
|
|
|
@ -224,6 +224,27 @@ class ConfigureTest extends CakeTestCase {
|
|||
$this->assertTrue($result === null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
3
cake/tests/test_app/plugins/test_plugin/config/load.php
Normal file
3
cake/tests/test_app/plugins/test_plugin/config/load.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
$config['plugin_load'] = '/test_app/plugins/test_plugin/config/load.php';
|
||||
?>
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
$config['plugin_more_load'] = '/test_app/plugins/test_plugin/config/more.load.php';
|
||||
?>
|
Loading…
Reference in a new issue