Setting up default config loader event.

Went ahead and just register the config.load event with Laravel on every request and default to the file implementation.

Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
This commit is contained in:
Taylor Otwell 2012-03-01 11:21:11 -06:00
parent be95496158
commit 16fa094cc3
4 changed files with 41 additions and 10 deletions

View File

@ -14,6 +14,23 @@
ini_set('display_errors', 'Off'); ini_set('display_errors', 'Off');
/*
|--------------------------------------------------------------------------
| Laravel Configuration Loader
|--------------------------------------------------------------------------
|
| The Laravel configuration loader is responsible for returning an array
| of configuration options for a given bundle and file. By default, we
| use the files provided with Laravel; however, you are free to use
| your own storage mechanism for configuration files.
|
*/
Laravel\Event::listen(Laravel\Config::loader, function($bundle, $file)
{
return Laravel\Config::file($bundle, $file);
});
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Register Class Aliases | Register Class Aliases

View File

@ -44,7 +44,7 @@ public static function run($arguments = array())
throw new \Exception("Sorry, I can't find that task."); throw new \Exception("Sorry, I can't find that task.");
} }
if(is_callable(array($task, $method))) if (is_callable(array($task, $method)))
{ {
$task->$method(array_slice($arguments, 1)); $task->$method(array_slice($arguments, 1));
} }
@ -114,7 +114,7 @@ public static function resolve($bundle, $task)
// First we'll check to see if the task has been registered in the // First we'll check to see if the task has been registered in the
// application IoC container. This allows all dependencies to be // application IoC container. This allows all dependencies to be
// injected into tasks for more testability. // injected into tasks for more flexible testability.
if (IoC::registered("task: {$identifier}")) if (IoC::registered("task: {$identifier}"))
{ {
return IoC::resolve("task: {$identifier}"); return IoC::resolve("task: {$identifier}");

View File

@ -175,14 +175,7 @@ public static function load($bundle, $file)
// We allow a "config.loader" event to be registered which is responsible for // We allow a "config.loader" event to be registered which is responsible for
// returning an array representing the configuration for the bundle and file // returning an array representing the configuration for the bundle and file
// requested. This allows many types of config "drivers". // requested. This allows many types of config "drivers".
if (Event::listeners(static::loader)) $config = Event::first(static::loader, func_get_args());
{
$config = Event::first(static::loader, func_get_args());
}
else
{
$config = static::file($bundle, $file);
}
// If configuration items were actually found for the bundle and file we // If configuration items were actually found for the bundle and file we
// will add them to the configuration array and return true, otherwise // will add them to the configuration array and return true, otherwise

View File

@ -141,6 +141,27 @@ public static function cli()
return defined('STDIN'); return defined('STDIN');
} }
/**
* Get the Laravel environment for the current request.
*
* @return string|null
*/
public static function env()
{
if (isset($_SERVER['LARAVEL_ENV'])) return $_SERVER['LARAVEL_ENV'];
}
/**
* Determine the current request environment.
*
* @param string $env
* @return bool
*/
public static function is_env($env)
{
return static::env() === $env;
}
/** /**
* Get the main route handling the request. * Get the main route handling the request.
* *