Skip to content

Commit

Permalink
Consolidate more configuration data.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Sep 18, 2012
1 parent ef7cc5a commit b4d655a
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 51 deletions.
15 changes: 13 additions & 2 deletions App/Config/app.php
Expand Up @@ -2,6 +2,7 @@
namespace App\Config;

use Cake\Core\Configure;
use Cake\Core\ClassLoader;

/**
* CakePHP Debug Level:
Expand All @@ -18,6 +19,12 @@
*/
Configure::write('debug', 2);

/**
* The root namespace your application uses. This should match
* the top level directory.
*/
$namespace = 'App';

/**
* Configure basic information about the application.
*
Expand All @@ -36,12 +43,16 @@
* - www_root - The file path to webroot.
*/
Configure::write('App', array(
'namespace' => 'App',
'namespace' => $namespace,
'encoding' => 'UTF-8',
'base' => false,
'baseUrl' => false,
//'baseUrl' => env('SCRIPT_NAME'),
'base' => false,
'dir' => APP_DIR,
'webroot' => WEBROOT_DIR,
'www_root' => WWW_ROOT,
));

$loader = new ClassLoader($namespace, dirname(APP));
$loader->register();
unset($loader, $namespace);
15 changes: 10 additions & 5 deletions App/Config/error.php
Expand Up @@ -17,11 +17,11 @@
*
* @see ErrorHandler for more information on error handling and configuration.
*/
Configure::write('Error', array(
$error = array(
'handler' => 'Cake\Error\ErrorHandler::handleError',
'level' => E_ALL & ~E_DEPRECATED,
'trace' => true
));
);

/**
* Configure the Exception handler used for uncaught exceptions. By default,
Expand All @@ -39,10 +39,15 @@
*
* @see ErrorHandler for more information on exception handling and configuration.
*/
Configure::write('Exception', array(
$exception = array(
'handler' => 'Cake\Error\ErrorHandler::handleException',
'renderer' => 'Cake\Error\ExceptionRenderer',
'log' => true
));
);

Configure::setErrorHandlers();
Configure::setErrorHandlers(
$error,
$exception
);

unset($error, $exception);
2 changes: 1 addition & 1 deletion App/Config/paths.php
Expand Up @@ -23,7 +23,7 @@
/**
* The name of the webroot dir. Defaults to 'webroot'
*/
define('WEBROOT_DIR', basename(dirname(__FILE__)));
define('WEBROOT_DIR', 'webroot');

/**
* File path to the webroot directory.
Expand Down
4 changes: 2 additions & 2 deletions App/Config/routes.php
Expand Up @@ -30,11 +30,11 @@
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/View/Pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'Pages', 'action' => 'display', 'home'));
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
Router::connect('/pages/*', array('controller' => 'Pages', 'action' => 'display'));
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));

/**
* Load all plugin routes. See the Plugin documentation on
Expand Down
3 changes: 0 additions & 3 deletions lib/Cake/Core/App.php
Expand Up @@ -536,9 +536,6 @@ public static function location($className) {
* @return void
*/
public static function init() {
$loader = new ClassLoader(Configure::read('App.namespace'), dirname(APP));
$loader->register();

register_shutdown_function(array(__CLASS__, 'shutdown'));
}

Expand Down
38 changes: 1 addition & 37 deletions lib/Cake/Core/Configure.php
Expand Up @@ -49,36 +49,6 @@ class Configure {
*/
protected static $_readers = array();

/**
* Initializes configure and runs the bootstrap process.
* Bootstrapping includes the following steps:
*
* - Setup App array in Configure.
* - Include app/Config/core.php.
* - Configure core cache configurations.
* - Load App cache files.
* - Include app/Config/bootstrap.php.
* - Setup error/exception handlers.
*
* @param boolean $boot
* @return void
*/
public static function bootstrap($boot = true) {
if ($boot) {
static::write('App', array(
'base' => false,
'baseUrl' => false,
'dir' => APP_DIR,
'webroot' => WEBROOT_DIR,
'www_root' => WWW_ROOT
));

App::init();
App::build();

}
}

/**
* Used to store a dynamic variable in Configure.
*
Expand Down Expand Up @@ -385,13 +355,7 @@ public static function clear() {
* @param array $exception The exception handling configuration.
* @return void
*/
public static function setErrorHandlers($error = null, $exception = null) {
if (!$error) {
$error = self::$_values['Error'];
}
if (!$exception) {
$exception = self::$_values['Exception'];
}
public static function setErrorHandlers($error, $exception) {
$level = -1;
if (isset($error['level'])) {
error_reporting($error['level']);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Routing/Dispatcher.php
Expand Up @@ -19,8 +19,8 @@
* @since CakePHP(tm) v 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

namespace Cake\Routing;

use Cake\Controller\Controller;
use Cake\Core\App;
use Cake\Core\Configure;
Expand Down
7 changes: 7 additions & 0 deletions lib/Cake/bootstrap.php
Expand Up @@ -27,6 +27,13 @@
$loader = new \Cake\Core\ClassLoader('Cake', CORE_PATH);
$loader->register();


use Cake\Core\App;
use Cake\Core\Configure;

App::init();
App::build();

/**
* Full url prefix
*/
Expand Down

0 comments on commit b4d655a

Please sign in to comment.