Browse Source

Move plugin's /src/Config to /config.

ADmad 11 years ago
parent
commit
e3f990f259

+ 3 - 3
src/Configure/Engine/IniConfig.php

@@ -15,7 +15,7 @@
 namespace Cake\Configure\Engine;
 
 use Cake\Configure\ConfigEngineInterface;
-use Cake\Core\App;
+use Cake\Core\Plugin;
 use Cake\Error;
 use Cake\Utility\Hash;
 
@@ -72,7 +72,7 @@ class IniConfig implements ConfigEngineInterface {
  * Build and construct a new ini file parser. The parser can be used to read
  * ini files that are on the filesystem.
  *
- * @param string $path Path to load ini config files from. Defaults to APP . 'Config' . DS
+ * @param string $path Path to load ini config files from. Defaults to CONFIG.
  * @param string $section Only get one section, leave null to parse and fetch
  *     all sections in the ini file.
  */
@@ -218,7 +218,7 @@ class IniConfig implements ConfigEngineInterface {
 		}
 
 		if ($plugin) {
-			$file = App::path('Config', $plugin)[0] . $key;
+			$file = Plugin::configPath($plugin) . $key;
 		} else {
 			$file = $this->_path . $key;
 		}

+ 4 - 4
src/Configure/Engine/PhpConfig.php

@@ -15,7 +15,7 @@
 namespace Cake\Configure\Engine;
 
 use Cake\Configure\ConfigEngineInterface;
-use Cake\Core\App;
+use Cake\Core\Plugin;
 use Cake\Error;
 
 /**
@@ -37,7 +37,7 @@ class PhpConfig implements ConfigEngineInterface {
 /**
  * Constructor for PHP Config file reading.
  *
- * @param string $path The path to read config files from. Defaults to APP . 'Config/'
+ * @param string $path The path to read config files from. Defaults to CONFIG.
  */
 	public function __construct($path = null) {
 		if (!$path) {
@@ -50,7 +50,7 @@ class PhpConfig implements ConfigEngineInterface {
  * Read a config file and return its contents.
  *
  * Files with `.` in the name will be treated as values in plugins. Instead of
- * reading from the initialized path, plugin keys will be located using App::path().
+ * reading from the initialized path, plugin keys will be located using Plugin::path().
  *
  * @param string $key The identifier to read from. If the key has a . it will be treated
  *  as a plugin prefix.
@@ -106,7 +106,7 @@ class PhpConfig implements ConfigEngineInterface {
 		$key .= '.php';
 
 		if ($plugin) {
-			$file = App::path('Config', $plugin)[0] . $key;
+			$file = Plugin::configPath($plugin) . $key;
 		} else {
 			$file = $this->_path . $key;
 		}

+ 19 - 2
src/Core/Plugin.php

@@ -149,6 +149,9 @@ class Plugin {
 		}
 
 		$config['classPath'] = $config['path'] . $config['classBase'] . DS;
+		if (!isset($config['configPath'])) {
+			$config['configPath'] = $config['path'] . 'config' . DS;
+		}
 
 		static::$_plugins[$plugin] = $config;
 
@@ -236,6 +239,20 @@ class Plugin {
 	}
 
 /**
+ * Returns the filesystem path for plugin's folder containing config files.
+ *
+ * @param string $plugin name of the plugin in CamelCase format.
+ * @return string Path to the plugin folder container config files.
+ * @throws \Cake\Core\Error\MissingPluginException If plugin has not been loaded.
+ */
+	public static function configPath($plugin) {
+		if (empty(static::$_plugins[$plugin])) {
+			throw new Error\MissingPluginException(['plugin' => $plugin]);
+		}
+		return static::$_plugins[$plugin]['configPath'];
+	}
+
+/**
  * Return the namespace for a plugin
  *
  * If a plugin is unknown, the plugin name will be used as the namespace.
@@ -266,7 +283,7 @@ class Plugin {
 		$path = static::path($plugin);
 		if ($config['bootstrap'] === true) {
 			return static::_includeFile(
-				$config['classPath'] . 'Config' . DS . 'bootstrap.php',
+				$config['configPath'] . 'bootstrap.php',
 				$config['ignoreMissing']
 			);
 		}
@@ -291,7 +308,7 @@ class Plugin {
 			return false;
 		}
 		return (bool)static::_includeFile(
-			$config['classPath'] . 'Config' . DS . 'routes.php',
+			$config['configPath'] . 'routes.php',
 			$config['ignoreMissing']
 		);
 	}

tests/test_app/Plugin/Company/TestPluginThree/src/Config/bootstrap.php → tests/test_app/Plugin/Company/TestPluginThree/config/bootstrap.php


tests/test_app/Plugin/PluginJs/src/Config/bootstrap.php → tests/test_app/Plugin/PluginJs/config/bootstrap.php


tests/test_app/Plugin/TestPlugin/src/Config/Schema/schema.php → tests/test_app/Plugin/TestPlugin/config/Schema/schema.php


tests/test_app/Plugin/TestPlugin/src/Config/acl.ini.php → tests/test_app/Plugin/TestPlugin/config/acl.ini.php


tests/test_app/Plugin/TestPlugin/src/Config/bootstrap.php → tests/test_app/Plugin/TestPlugin/config/bootstrap.php


tests/test_app/Plugin/TestPlugin/src/Config/custom_config.php → tests/test_app/Plugin/TestPlugin/config/custom_config.php


tests/test_app/Plugin/TestPlugin/src/Config/load.php → tests/test_app/Plugin/TestPlugin/config/load.php


tests/test_app/Plugin/TestPlugin/src/Config/more.load.php → tests/test_app/Plugin/TestPlugin/config/more.load.php


tests/test_app/Plugin/TestPlugin/src/Config/nested.ini → tests/test_app/Plugin/TestPlugin/config/nested.ini


tests/test_app/Plugin/TestPlugin/src/Config/routes.php → tests/test_app/Plugin/TestPlugin/config/routes.php


tests/test_app/Plugin/TestPlugin/src/Config/test_templates.php → tests/test_app/Plugin/TestPlugin/config/test_templates.php


tests/test_app/Plugin/TestPluginFour/Config/bootstrap.php → tests/test_app/Plugin/TestPluginFour/config/bootstrap.php


tests/test_app/Plugin/TestPluginTwo/src/Config/bootstrap.php → tests/test_app/Plugin/TestPluginTwo/config/bootstrap.php