From be9549615861a627568d568974d968d5b6f2d944 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 1 Mar 2012 10:55:37 -0600 Subject: [PATCH] Allowing for config.load event. Moved more basic logic into application start to make it easier to hook into early life cycle events such as configuration loading while not introducing extra files into the framework. Signed-off-by: Taylor Otwell --- application/config/error.php | 17 ---------- application/start.php | 61 ++++++++++++++++++++++++++++++++++++ laravel/config.php | 49 ++++++++++++++++++++++++----- laravel/core.php | 23 ++------------ laravel/laravel.php | 14 --------- laravel/session.php | 14 ++++++++- 6 files changed, 118 insertions(+), 60 deletions(-) diff --git a/application/config/error.php b/application/config/error.php index cebdae8a..87db9665 100644 --- a/application/config/error.php +++ b/application/config/error.php @@ -66,21 +66,4 @@ return array( Log::exception($exception); }, - /* - |-------------------------------------------------------------------------- - | PHP INI Display Errors Setting - |-------------------------------------------------------------------------- - | - | Here you may specify the display_errors setting of the PHP.ini file. - | Typically you may keep this "Off", as Laravel will cleanly handle - | the display of all errors. - | - | However, if you encounter an infamous white screen of death scenario, - | turning this "On" may help you solve the problem by getting the - | real error message being thrown by the application. - | - */ - - 'display' => 'Off', - ); \ No newline at end of file diff --git a/application/start.php b/application/start.php index a4725849..502339a1 100644 --- a/application/start.php +++ b/application/start.php @@ -1,5 +1,66 @@ 0) + { + static::$items[$bundle][$file] = $config; + } + + return isset(static::$items[$bundle][$file]); + } + + /** + * Load the configuration items from a configuration file. + * + * @param string $bundle + * @param string $file + * @return array + */ + public static function file($bundle, $file) + { $config = array(); // Configuration files cascade. Typically, the bundle configuration array is @@ -179,12 +217,7 @@ class Config { } } - if (count($config) > 0) - { - static::$items[$bundle][$file] = $config; - } - - return isset(static::$items[$bundle][$file]); + return $config; } /** diff --git a/laravel/core.php b/laravel/core.php index a03d2cc6..4947cdf6 100644 --- a/laravel/core.php +++ b/laravel/core.php @@ -64,26 +64,9 @@ if (isset($_SERVER['CLI']['ENV'])) } /** - * Register all of the core class aliases. These aliases provide a - * convenient way of working with the Laravel core classes without - * having to worry about the namespacing. The developer is also - * free to remove aliases when they extend core classes. - */ -Autoloader::$aliases = Config::get('application.aliases'); - -/** - * Register the default timezone for the application. This will - * be the default timezone used by all date functions through - * throughout the entire application. - */ -$timezone = Config::get('application.timezone'); - -date_default_timezone_set($timezone); - -/** - * Finally we'll grab all of the bundles and register them - * with the bundle class. All of the bundles are stored in - * an array within the application directory. + * Finally we'll grab all of the bundles and register them with the + * bundle class. All of the bundles are stored in an array within + * the application directory which defines all bundles. */ $bundles = require path('app').'bundles'.EXT; diff --git a/laravel/laravel.php b/laravel/laravel.php index 43ea0658..a7cad554 100644 --- a/laravel/laravel.php +++ b/laravel/laravel.php @@ -50,8 +50,6 @@ register_shutdown_function(function() */ error_reporting(-1); -ini_set('display_errors', Config::get('error.display')); - /** * Even though "Magic Quotes" are deprecated in PHP 5.3, they may * still be enabled on the server. To account for this, we will @@ -68,18 +66,6 @@ if (magic_quotes()) } } -/** - * Load the session using the session manager. The payload will - * be set on a static property of the Session class for easy - * access throughout the framework and application. - */ -if (Config::get('session.driver') !== '') -{ - Session::start(Config::get('session.driver')); - - Session::load(Cookie::get(Config::get('session.cookie'))); -} - /** * Gather the input to the application based on the global input * variables for the current request. The input will be gathered diff --git a/laravel/session.php b/laravel/session.php index ee997776..2e3044db 100644 --- a/laravel/session.php +++ b/laravel/session.php @@ -17,7 +17,19 @@ class Session { const csrf_token = 'csrf_token'; /** - * Create the session payload instance and load the session for the request. + * Create the session payload and the load the session. + * + * @return void + */ + public static function load() + { + static::start(Config::get('session.driver')); + + static::$instance->load(Cookie::get(Config::get('session.cookie'))); + } + + /** + * Create the session payload instance for the request. * * @param string $driver * @return void