Merge pull request #10647 from josephzidell/2.next-custom-config-dir-loc

Add constant specifying the location of the Config dir
This commit is contained in:
Mark Story 2017-05-14 21:41:09 -04:00 committed by GitHub
commit 57ddc24b35
31 changed files with 72 additions and 51 deletions

View file

@ -58,11 +58,11 @@ endif;
$settings = Cache::settings();
if (!empty($settings)):
echo '<span class="notice success">';
echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit %s', '<em>' . $settings['engine'] . 'Engine</em>', 'APP/Config/core.php');
echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit %s', '<em>' . $settings['engine'] . 'Engine</em>', CONFIG . 'core.php');
echo '</span>';
else:
echo '<span class="notice">';
echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in %s', 'APP/Config/core.php');
echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in %s', CONFIG . 'core.php');
echo '</span>';
endif;
?>
@ -70,7 +70,7 @@ endif;
<p>
<?php
$filePresent = null;
if (file_exists(APP . 'Config' . DS . 'database.php')):
if (file_exists(CONFIG . 'database.php')):
echo '<span class="notice success">';
echo __d('cake_dev', 'Your database configuration file is present.');
$filePresent = true;
@ -79,7 +79,7 @@ endif;
echo '<span class="notice">';
echo __d('cake_dev', 'Your database configuration file is NOT present.');
echo '<br/>';
echo __d('cake_dev', 'Rename %s to %s', 'APP/Config/database.php.default', 'APP/Config/database.php');
echo __d('cake_dev', 'Rename %s to %s', CONFIG . 'database.php.default', CONFIG . 'database.php');
echo '</span>';
endif;
?>

View file

@ -43,6 +43,13 @@ if (!defined('APP_DIR')) {
define('APP_DIR', basename(dirname(dirname(__FILE__))));
}
/**
* Config Directory
*/
if (!defined('CONFIG')) {
define('CONFIG', ROOT . DS . APP_DIR . DS . 'Config' . DS);
}
/**
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
*

View file

@ -46,6 +46,13 @@ if (!defined('APP_DIR')) {
define('APP_DIR', basename(dirname(dirname(__FILE__))));
}
/**
* Config Directory
*/
if (!defined('CONFIG')) {
define('CONFIG', ROOT . DS . APP_DIR . DS . 'Config' . DS);
}
/**
* The absolute path to the "Cake" directory, WITHOUT a trailing DS.
*

View file

@ -38,7 +38,7 @@
* - `/:controller'
* - `/:controller/:action/*'
*
* You can disable the connection of default routes by deleting the require inside APP/Config/routes.php.
* You can disable the connection of default routes by deleting the require inside CONFIG/routes.php.
*/
$prefixes = Router::prefixes();

View file

@ -73,13 +73,13 @@ class IniReader implements ConfigReaderInterface {
* 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.
*/
public function __construct($path = null, $section = null) {
if (!$path) {
$path = APP . 'Config' . DS;
$path = CONFIG;
}
$this->_path = $path;
$this->_section = $section;

View file

@ -38,11 +38,11 @@ class PhpReader implements ConfigReaderInterface {
/**
* Constructor for PHP Config file reading.
*
* @param string $path The path to read config files from. Defaults to APP . 'Config' . DS
* @param string $path The path to read config files from. Defaults to CONFIG
*/
public function __construct($path = null) {
if (!$path) {
$path = APP . 'Config' . DS;
$path = CONFIG;
}
$this->_path = $path;
}

View file

@ -89,7 +89,7 @@ class AclShell extends AppShell {
$this->args = null;
return $this->DbConfig->execute();
}
require_once APP . 'Config' . DS . 'database.php';
require_once CONFIG . 'database.php';
if (!in_array($this->command, array('initdb'))) {
$collection = new ComponentCollection();

View file

@ -501,7 +501,7 @@ class ConsoleShell extends AppShell {
extract(Router::getNamedExpressions());
//@codingStandardsIgnoreStart
if (!@include APP . 'Config' . DS . 'routes.php') {
if (!@include CONFIG . 'routes.php') {
//@codingStandardsIgnoreEnd
return false;
}

View file

@ -476,7 +476,7 @@ class SchemaShell extends AppShell {
);
$path = array(
'help' => __d('cake_console', 'Path to read and write schema.php'),
'default' => APP . 'Config' . DS . 'Schema'
'default' => CONFIG . 'Schema'
);
$file = array(
'help' => __d('cake_console', 'File name to read and write.'),

View file

@ -64,7 +64,7 @@ class DbConfigTask extends AppShell {
* @return void
*/
public function initialize() {
$this->path = APP . 'Config' . DS;
$this->path = CONFIG;
}
/**

View file

@ -45,7 +45,7 @@ class PluginTask extends AppShell {
*/
public function initialize() {
$this->path = current(App::path('plugins'));
$this->bootstrap = APP . 'Config' . DS . 'bootstrap.php';
$this->bootstrap = CONFIG . 'bootstrap.php';
}
/**

View file

@ -79,14 +79,14 @@ class ProjectTask extends AppShell {
if ($this->securitySalt($path) === true) {
$this->out(__d('cake_console', ' * Random hash key created for \'Security.salt\''));
} else {
$this->err(__d('cake_console', 'Unable to generate random hash for \'Security.salt\', you should change it in %s', APP . 'Config' . DS . 'core.php'));
$this->err(__d('cake_console', 'Unable to generate random hash for \'Security.salt\', you should change it in %s', CONFIG . 'core.php'));
$success = false;
}
if ($this->securityCipherSeed($path) === true) {
$this->out(__d('cake_console', ' * Random seed created for \'Security.cipherSeed\''));
} else {
$this->err(__d('cake_console', 'Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', APP . 'Config' . DS . 'core.php'));
$this->err(__d('cake_console', 'Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', CONFIG . 'core.php'));
$success = false;
}
@ -362,7 +362,7 @@ class ProjectTask extends AppShell {
* @return bool Success
*/
public function cakeAdmin($name) {
$path = (empty($this->configPath)) ? APP . 'Config' . DS : $this->configPath;
$path = (empty($this->configPath)) ? CONFIG : $this->configPath;
$File = new File($path . 'core.php');
$contents = $File->read();
if (preg_match('%(\s*[/]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(]*\);)%', $contents, $match)) {

View file

@ -144,7 +144,7 @@ class ShellDispatcher {
$boot = file_exists(ROOT . DS . APP_DIR . DS . 'Config' . DS . 'bootstrap.php');
require CORE_PATH . 'Cake' . DS . 'bootstrap.php';
if (!file_exists(APP . 'Config' . DS . 'core.php')) {
if (!file_exists(CONFIG . 'core.php')) {
include_once CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 'Templates' . DS . 'skel' . DS . 'Config' . DS . 'core.php';
App::build();
}

View file

@ -62,11 +62,11 @@ endif;
$settings = Cache::settings();
if (!empty($settings)):
echo '<span class="notice success">';
echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit %s', '<em>' . $settings['engine'] . 'Engine</em>', 'APP/Config/core.php');
echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit %s', '<em>' . $settings['engine'] . 'Engine</em>', CONFIG . 'core.php');
echo '</span>';
else:
echo '<span class="notice">';
echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in %s', 'APP/Config/core.php');
echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in %s', CONFIG . 'core.php');
echo '</span>';
endif;
?>
@ -74,7 +74,7 @@ endif;
<p>
<?php
$filePresent = null;
if (file_exists(APP . 'Config' . DS . 'database.php')):
if (file_exists(CONFIG . 'database.php')):
echo '<span class="notice success">';
echo __d('cake_dev', 'Your database configuration file is present.');
$filePresent = true;
@ -83,7 +83,7 @@ endif;
echo '<span class="notice">';
echo __d('cake_dev', 'Your database configuration file is NOT present.');
echo '<br/>';
echo __d('cake_dev', 'Rename %s to %s', 'APP/Config/database.php.default', 'APP/Config/database.php');
echo __d('cake_dev', 'Rename %s to %s', CONFIG . 'database.php.default', CONFIG . 'database.php');
echo '</span>';
endif;
?>

View file

@ -94,7 +94,7 @@ class IniAcl extends CakeObject implements AclInterface {
*/
public function check($aro, $aco, $action = null) {
if (!$this->config) {
$this->config = $this->readConfigFile(APP . 'Config' . DS . 'acl.ini.php');
$this->config = $this->readConfigFile(CONFIG . 'acl.ini.php');
}
$aclConfig = $this->config;

View file

@ -69,7 +69,7 @@ class PhpAcl extends CakeObject implements AclInterface {
public function __construct() {
$this->options = array(
'policy' => static::DENY,
'config' => APP . 'Config' . DS . 'acl.php',
'config' => CONFIG . 'acl.php',
);
}

View file

@ -69,10 +69,10 @@ class Configure {
if ($boot) {
static::_appDefaults();
if (!include APP . 'Config' . DS . 'core.php') {
if (!include CONFIG . 'core.php') {
trigger_error(__d('cake_dev',
"Can't find application core file. Please create %s, and make sure it is readable by PHP.",
APP . 'Config' . DS . 'core.php'),
CONFIG . 'core.php'),
E_USER_ERROR
);
}
@ -95,10 +95,10 @@ class Configure {
}
static::_setErrorHandlers($error, $exception);
if (!include APP . 'Config' . DS . 'bootstrap.php') {
if (!include CONFIG . 'bootstrap.php') {
trigger_error(__d('cake_dev',
"Can't find application bootstrap file. Please create %s, and make sure it is readable by PHP.",
APP . 'Config' . DS . 'bootstrap.php'),
CONFIG . 'bootstrap.php'),
E_USER_ERROR
);
}

View file

@ -90,7 +90,7 @@ class CakeSchema extends CakeObject {
}
if (empty($options['path'])) {
$this->path = APP . 'Config' . DS . 'Schema';
$this->path = CONFIG . 'Schema';
}
$options = array_merge(get_object_vars($this), $options);

View file

@ -64,7 +64,7 @@ class ConnectionManager {
* @return void
*/
protected static function _init() {
include_once APP . 'Config' . DS . 'database.php';
include_once CONFIG . 'database.php';
if (class_exists('DATABASE_CONFIG')) {
static::$config = new DATABASE_CONFIG();
}

View file

@ -1241,7 +1241,7 @@ class CakeEmail {
if (is_string($config)) {
if (!$this->_configInstance) {
if (!class_exists($this->_configClass) && !config('email')) {
throw new ConfigureException(__d('cake_dev', '%s not found.', APP . 'Config' . DS . 'email.php'));
throw new ConfigureException(__d('cake_dev', '%s not found.', CONFIG . 'email.php'));
}
$this->_configInstance = new $this->_configClass();
}

View file

@ -1281,7 +1281,7 @@ class Router {
*/
protected static function _loadRoutes() {
static::$initialized = true;
include APP . 'Config' . DS . 'routes.php';
include CONFIG . 'routes.php';
}
}

View file

@ -147,7 +147,7 @@ class SchemaShellTest extends CakeTestCase {
$this->assertEquals('TestSchema', $this->Shell->Schema->name);
$this->assertEquals('test_schema.php', $this->Shell->Schema->file);
$this->assertEquals('default', $this->Shell->Schema->connection);
$this->assertEquals(APP . 'Config' . DS . 'Schema', $this->Shell->Schema->path);
$this->assertEquals(CONFIG . 'Schema', $this->Shell->Schema->path);
$this->Shell->Schema = null;
$this->Shell->params = array(
@ -169,7 +169,7 @@ class SchemaShellTest extends CakeTestCase {
*/
public function testView() {
$this->Shell->startup();
$this->Shell->Schema->path = APP . 'Config' . DS . 'Schema';
$this->Shell->Schema->path = CONFIG . 'Schema';
$this->Shell->params['file'] = 'i18n.php';
$this->Shell->expects($this->once())->method('_stop');
$this->Shell->expects($this->once())->method('out');
@ -485,7 +485,7 @@ class SchemaShellTest extends CakeTestCase {
$this->Shell->params = array(
'connection' => 'test',
'name' => 'I18n',
'path' => APP . 'Config' . DS . 'Schema'
'path' => CONFIG . 'Schema'
);
$this->Shell->args = array('I18n', 'i18n');
$this->Shell->startup();

View file

@ -44,7 +44,7 @@ class DbConfigTaskTest extends CakeTestCase {
array($out, $out, $in)
);
$this->Task->path = APP . 'Config' . DS;
$this->Task->path = CONFIG;
}
/**
@ -79,7 +79,7 @@ class DbConfigTaskTest extends CakeTestCase {
public function testInitialize() {
$this->Task->initialize();
$this->assertFalse(empty($this->Task->path));
$this->assertEquals(APP . 'Config' . DS, $this->Task->path);
$this->assertEquals(CONFIG, $this->Task->path);
}
/**

View file

@ -312,7 +312,7 @@ class ProjectTaskTest extends CakeTestCase {
* @return void
*/
public function testCakeAdmin() {
$File = new File(APP . 'Config' . DS . 'core.php');
$File = new File(CONFIG . 'core.php');
$contents = $File->read();
$File = new File(TMP . 'tests' . DS . 'core.php');
$File->write($contents);

View file

@ -153,7 +153,7 @@ class CakeEmailTest extends CakeTestCase {
parent::setUp();
$this->_configFileExists = true;
$emailConfig = new File(APP . 'Config' . DS . 'email.php');
$emailConfig = new File(CONFIG . 'email.php');
if (!$emailConfig->exists()) {
$this->_configFileExists = false;
$emailConfig->create();
@ -176,7 +176,7 @@ class CakeEmailTest extends CakeTestCase {
App::build();
if (!$this->_configFileExists) {
unlink(APP . 'Config' . DS . 'email.php');
unlink(CONFIG . 'email.php');
}
}

View file

@ -16,11 +16,11 @@
$settings = Cache::settings();
if (!empty($settings)):
echo '<span class="notice success">';
echo __d('cake_dev', 'The %s is being used for caching. To change the config edit APP/config/core.php ', '<em>'. $settings['engine'] . 'Engine</em>');
echo __d('cake_dev', 'The %s is being used for caching. To change the config edit %s/core.php ', '<em>'. $settings['engine'] . 'Engine</em>', CONFIG);
echo '</span>';
else:
echo '<span class="notice">';
echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in APP/config/core.php');
echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in %s/core.php', CONFIG);
echo '</span>';
endif;
?>
@ -28,7 +28,7 @@
<p>
<?php
$filePresent = null;
if (file_exists(APP . 'Config' . DS . 'database.php')):
if (file_exists(CONFIG . 'database.php')):
echo '<span class="notice success">';
echo __d('cake_dev', 'Your database configuration file is present.');
$filePresent = true;

View file

@ -47,7 +47,7 @@
<?php
echo __d('cake', 'Your database configuration file is ');
$filePresent = null;
if (file_exists(APP . 'Config' . 'database.php')):
if (file_exists(CONFIG . 'database.php')):
echo __d('cake', 'present.');
$filePresent = true;
else:

View file

@ -837,11 +837,11 @@ class Debugger {
*/
public static function checkSecurityKeys() {
if (Configure::read('Security.salt') === 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi') {
trigger_error(__d('cake_dev', 'Please change the value of %s in %s to a salt value specific to your application.', '\'Security.salt\'', 'APP/Config/core.php'), E_USER_NOTICE);
trigger_error(__d('cake_dev', 'Please change the value of %s in %s to a salt value specific to your application.', '\'Security.salt\'', CONFIG . 'core.php'), E_USER_NOTICE);
}
if (Configure::read('Security.cipherSeed') === '76859309657453542496749683645') {
trigger_error(__d('cake_dev', 'Please change the value of %s in %s to a numeric (digits only) seed value specific to your application.', '\'Security.cipherSeed\'', 'APP/Config/core.php'), E_USER_NOTICE);
trigger_error(__d('cake_dev', 'Please change the value of %s in %s to a numeric (digits only) seed value specific to your application.', '\'Security.cipherSeed\'', CONFIG . 'core.php'), E_USER_NOTICE);
}
}

View file

@ -1217,7 +1217,7 @@ class HtmlHelper extends AppHelper {
/**
* Load Html tag configuration.
*
* Loads a file from APP/Config that contains tag data. By default the file is expected
* Loads a file from CONFIG that contains tag data. By default the file is expected
* to be compatible with PhpReader:
*
* `$this->Html->loadConfig('tags.php');`
@ -1236,7 +1236,7 @@ class HtmlHelper extends AppHelper {
* `$this->Html->loadConfig(array('tags.ini', 'ini'));`
*
* Its expected that the `tags` index will exist from any configuration file that is read.
* You can also specify the path to read the configuration file from, if APP/Config is not
* You can also specify the path to read the configuration file from, if CONFIG is not
* where the file is.
*
* `$this->Html->loadConfig('tags.php', APP . 'Lib' . DS);`
@ -1257,7 +1257,7 @@ class HtmlHelper extends AppHelper {
*/
public function loadConfig($configFile, $path = null) {
if (!$path) {
$path = APP . 'Config' . DS;
$path = CONFIG;
}
$file = null;
$reader = 'php';

View file

@ -46,8 +46,8 @@ if (!function_exists('config')) {
$count = count($args);
$included = 0;
foreach ($args as $arg) {
if (file_exists(APP . 'Config' . DS . $arg . '.php')) {
include_once APP . 'Config' . DS . $arg . '.php';
if (file_exists(CONFIG . $arg . '.php')) {
include_once CONFIG . $arg . '.php';
$included++;
}
}

View file

@ -53,6 +53,13 @@ if (!defined('APP')) {
define('APP', ROOT . DS . APP_DIR . DS);
}
/**
* Config Directory
*/
if (!defined('CONFIG')) {
define('CONFIG', ROOT . DS . APP_DIR . DS . 'Config' . DS);
}
/**
* Path to the application's libs directory.
*/