Commit a440f0e1 authored by Taylor Otwell's avatar Taylor Otwell

modular refactoring on the configuration and module classes.

parent d9f2ba84
......@@ -46,6 +46,9 @@ class Config {
*
* // Get the SQLite database connection configuration
* $sqlite = Config::get('db.connections.sqlite');
*
* // Get a configuration item from a module configuration file
* $option = Config::get('module::file.option');
* </code>
*
* @param string $key
......
......@@ -44,7 +44,7 @@ define('DEFAULT_MODULE', 'application');
// --------------------------------------------------------------
// Register the active modules.
// --------------------------------------------------------------
Module::$modules = array_merge(array('application' => 'application'), $active);
Module::$modules = array_merge(array('application'), $active);
unset($active);
......
......@@ -5,21 +5,35 @@ class Module {
/**
* The active modules for the installation.
*
* This property is set in the Laravel bootstrap file, and the modules are defined
* by the developer in the front controller.
*
* @var array
*/
public static $modules = array();
/**
* All of the loaded module paths.
* All of the loaded module paths keyed by name.
*
* These are stored as the module paths are determined for convenient, fast access.
*
* @var array
*/
private static $paths = array();
/**
* Parse a modularized identifier and get the module and key.
* Parse a modularized identifier and return the module and key.
*
* Modular identifiers follow typically follow a {module}::{key} convention.
* However, for convenience, the default module does not require a module qualifier.
*
* <code>
* // Returns array('admin', 'test.example')
* Module::parse('admin::test.example');
*
* Modular identifiers follow a {module}::{key} convention.
* // Returns array('application', 'test.example')
* Module::parse('test.example');
* </code>
*
* @param string $key
* @return array
......@@ -36,6 +50,10 @@ class Module {
/**
* Get the path for a given module.
*
* If the module exists in the module array as a key, that means a path other than
* the default path has been specified for the module. Otherwise, the module directory
* is assumed to have the same name as the module.
*
* @param string $module
* @return string
*/
......@@ -43,7 +61,11 @@ class Module {
{
if (array_key_exists($module, static::$paths)) return static::$paths[$module];
if (array_key_exists($module, static::$modules))
if (in_array($module, static::$modules))
{
return static::$paths[$module] = MODULE_PATH.$module.'/';
}
elseif (array_key_exists($module, static::$modules))
{
return static::$paths[$module] = MODULE_PATH.static::$modules[$module].'/';
}
......@@ -52,9 +74,6 @@ class Module {
/**
* Get the an array of paths to all of the modules.
*
* The module paths will be determined by the modules that are specified in the application
* modules configuration item. A trailing slash will be added to the paths.
*
* @return array
*/
public static function paths()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment