Commit d9f2ba84 authored by Taylor Otwell's avatar Taylor Otwell

2.0 modular refactoring.

parent 4569ebec
...@@ -18,31 +18,31 @@ return array( ...@@ -18,31 +18,31 @@ return array(
| |
*/ */
'Asset' => 'Laravel\\Asset', 'Asset' => 'Laravel\\Asset',
'Auth' => 'Laravel\\Auth', 'Auth' => 'Laravel\\Auth',
'Benchmark' => 'Laravel\\Benchmark', 'Benchmark' => 'Laravel\\Benchmark',
'Cache' => 'Laravel\\Cache', 'Cache' => 'Laravel\\Cache',
'Config' => 'Laravel\\Config', 'Config' => 'Laravel\\Config',
'Cookie' => 'Laravel\\Cookie', 'Cookie' => 'Laravel\\Cookie',
'Crypter' => 'Laravel\\Crypter', 'Crypter' => 'Laravel\\Crypter',
'DB' => 'Laravel\\DB', 'DB' => 'Laravel\\DB',
'Eloquent' => 'Laravel\\DB\\Eloquent\\Model', 'Eloquent' => 'Laravel\\DB\\Eloquent\\Model',
'File' => 'Laravel\\File', 'File' => 'Laravel\\File',
'Form' => 'Laravel\\Form', 'Form' => 'Laravel\\Form',
'Hash' => 'Laravel\\Hash', 'Hash' => 'Laravel\\Hash',
'HTML' => 'Laravel\\HTML', 'HTML' => 'Laravel\\HTML',
'Inflector' => 'Laravel\\Inflector', 'Inflector' => 'Laravel\\Inflector',
'Input' => 'Laravel\\Input', 'Input' => 'Laravel\\Input',
'Lang' => 'Laravel\\Lang', 'Lang' => 'Laravel\\Lang',
'Loader' => 'Laravel\\Loader', 'Loader' => 'Laravel\\Loader',
'Package' => 'Laravel\\Package', 'Package' => 'Laravel\\Package',
'URL' => 'Laravel\\URL', 'URL' => 'Laravel\\URL',
'Redirect' => 'Laravel\\Redirect', 'Redirect' => 'Laravel\\Redirect',
'Request' => 'Laravel\\Request', 'Request' => 'Laravel\\Request',
'Response' => 'Laravel\\Response', 'Response' => 'Laravel\\Response',
'Session' => 'Laravel\\Session', 'Session' => 'Laravel\\Session',
'Str' => 'Laravel\\Str', 'Str' => 'Laravel\\Str',
'Validator' => 'Laravel\\Validator', 'Validator' => 'Laravel\\Validator',
'View' => 'Laravel\\View', 'View' => 'Laravel\\View',
); );
\ No newline at end of file
...@@ -67,14 +67,12 @@ class Lang { ...@@ -67,14 +67,12 @@ class Lang {
list($module, $file, $line) = $this->parse($this->key, $language); list($module, $file, $line) = $this->parse($this->key, $language);
$this->load($module, $file, $language); if ( ! $this->load($module, $file, $language))
if ( ! isset(static::$lines[$module][$language.$file][$line]))
{ {
return is_callable($default) ? call_user_func($default) : $default; return is_callable($default) ? call_user_func($default) : $default;
} }
$line = static::$lines[$module][$language.$file][$line]; $line = Arr::get(static::$lines[$module][$language.$file], $line, $default);
foreach ($this->replacements as $key => $value) foreach ($this->replacements as $key => $value)
{ {
...@@ -109,16 +107,22 @@ class Lang { ...@@ -109,16 +107,22 @@ class Lang {
* @param string $module * @param string $module
* @param string $file * @param string $file
* @param string $language * @param string $language
* @return void * @return bool
*/ */
private function load($module, $file, $language) private function load($module, $file, $language)
{ {
if (isset(static::$lines[$module][$language.$file])) return; if (isset(static::$lines[$module][$language.$file])) return;
if (file_exists($path = Module::path($module).'lang/'.$language.'/'.$file.EXT)) $lang = array();
foreach (array(LANG_PATH, Module::path($module).'lang/') as $directory)
{ {
static::$lines[$module][$language.$file] = require $path; $lang = (file_exists($path = $directory.$language.'/'.$file.EXT)) ? array_merge($lang, require $path) : $lang;
} }
if (count($lang) > 0) static::$lines[$module][$language.$file] = $lang;
return isset(static::$lines[$module][$language.$file]);
} }
/** /**
......
...@@ -9,7 +9,6 @@ define('EXT', '.php'); ...@@ -9,7 +9,6 @@ define('EXT', '.php');
// Define the core framework paths. // Define the core framework paths.
// -------------------------------------------------------------- // --------------------------------------------------------------
define('BASE_PATH', realpath(str_replace('laravel', '', $system)).'/'); define('BASE_PATH', realpath(str_replace('laravel', '', $system)).'/');
define('CONFIG_PATH', realpath($config).'/');
define('MODULE_PATH', realpath($modules).'/'); define('MODULE_PATH', realpath($modules).'/');
define('PACKAGE_PATH', realpath($packages).'/'); define('PACKAGE_PATH', realpath($packages).'/');
define('PUBLIC_PATH', realpath($public).'/'); define('PUBLIC_PATH', realpath($public).'/');
...@@ -22,16 +21,13 @@ unset($system, $config, $modules, $packages, $public, $storage); ...@@ -22,16 +21,13 @@ unset($system, $config, $modules, $packages, $public, $storage);
// Define various other framework paths. // Define various other framework paths.
// -------------------------------------------------------------- // --------------------------------------------------------------
define('CACHE_PATH', STORAGE_PATH.'cache/'); define('CACHE_PATH', STORAGE_PATH.'cache/');
define('CONFIG_PATH', SYS_PATH.'config/');
define('DATABASE_PATH', STORAGE_PATH.'db/'); define('DATABASE_PATH', STORAGE_PATH.'db/');
define('LANG_PATH', SYS_PATH.'lang/');
define('SCRIPT_PATH', PUBLIC_PATH.'js/'); define('SCRIPT_PATH', PUBLIC_PATH.'js/');
define('SESSION_PATH', STORAGE_PATH.'sessions/'); define('SESSION_PATH', STORAGE_PATH.'sessions/');
define('STYLE_PATH', PUBLIC_PATH.'css/'); define('STYLE_PATH', PUBLIC_PATH.'css/');
// --------------------------------------------------------------
// Define the default module.
// --------------------------------------------------------------
define('DEFAULT_MODULE', 'application');
// -------------------------------------------------------------- // --------------------------------------------------------------
// Load the classes used by the auto-loader. // Load the classes used by the auto-loader.
// -------------------------------------------------------------- // --------------------------------------------------------------
...@@ -40,13 +36,23 @@ require SYS_PATH.'config'.EXT; ...@@ -40,13 +36,23 @@ require SYS_PATH.'config'.EXT;
require SYS_PATH.'module'.EXT; require SYS_PATH.'module'.EXT;
require SYS_PATH.'arr'.EXT; require SYS_PATH.'arr'.EXT;
// --------------------------------------------------------------
// Define the default module.
// --------------------------------------------------------------
define('DEFAULT_MODULE', 'application');
// -------------------------------------------------------------- // --------------------------------------------------------------
// Register the active modules. // Register the active modules.
// -------------------------------------------------------------- // --------------------------------------------------------------
Module::$modules = $active; Module::$modules = array_merge(array('application' => 'application'), $active);
unset($active); unset($active);
// --------------------------------------------------------------
// Define the default module path.
// --------------------------------------------------------------
define('DEFAULT_MODULE_PATH', Module::path(DEFAULT_MODULE));
// -------------------------------------------------------------- // --------------------------------------------------------------
// Register the auto-loader. // Register the auto-loader.
// -------------------------------------------------------------- // --------------------------------------------------------------
...@@ -142,6 +148,11 @@ define('ACTIVE_MODULE', (array_key_exists($segments[0], Module::$modules)) ? $se ...@@ -142,6 +148,11 @@ define('ACTIVE_MODULE', (array_key_exists($segments[0], Module::$modules)) ? $se
// -------------------------------------------------------------- // --------------------------------------------------------------
define('ACTIVE_MODULE_PATH', Module::path(ACTIVE_MODULE)); define('ACTIVE_MODULE_PATH', Module::path(ACTIVE_MODULE));
// --------------------------------------------------------------
// Register the filters for the default module.
// --------------------------------------------------------------
Routing\Filter::register(require DEFAULT_MODULE_PATH.'filters'.EXT);
// -------------------------------------------------------------- // --------------------------------------------------------------
// Register the filters for the active module. // Register the filters for the active module.
// -------------------------------------------------------------- // --------------------------------------------------------------
......
...@@ -43,9 +43,10 @@ class Module { ...@@ -43,9 +43,10 @@ class Module {
{ {
if (array_key_exists($module, static::$paths)) return static::$paths[$module]; if (array_key_exists($module, static::$paths)) return static::$paths[$module];
if (array_key_exists($module, static::$modules)) $path = MODULE_PATH.static::$modules[$module].'/'; if (array_key_exists($module, static::$modules))
{
return static::$paths[$module] = $path; return static::$paths[$module] = MODULE_PATH.static::$modules[$module].'/';
}
} }
/** /**
......
<?php
return array(
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| The URL used to access your application. No trailing slash.
|
*/
'url' => 'http://localhost',
/*
|--------------------------------------------------------------------------
| Application Index
|--------------------------------------------------------------------------
|
| If you are including the "index.php" in your URLs, you can ignore this.
|
| However, if you are using mod_rewrite or something similar to get
| cleaner URLs, set this option to an empty string.
|
*/
'index' => 'index.php',
/*
|--------------------------------------------------------------------------
| Application Language
|--------------------------------------------------------------------------
|
| The default language of your application. This language will be used by
| Lang library as the default language when doing string localization.
|
*/
'language' => 'en',
/*
|--------------------------------------------------------------------------
| Application Character Encoding
|--------------------------------------------------------------------------
|
| The default character encoding used by your application. This is the
| character encoding that will be used by the Str, Text, and Form classes.
|
*/
'encoding' => 'UTF-8',
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| The default timezone of your application. This timezone will be used when
| Laravel needs a date, such as when writing to a log file.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Auto-Loaded Packages
|--------------------------------------------------------------------------
|
| The packages that should be auto-loaded each time Laravel handles
| a request. These should generally be packages that you use on almost
| every request to your application.
|
| Each package specified here will be bootstrapped and can be conveniently
| used by your application's routes, models, and libraries.
|
| Note: The package names in this array should correspond to a package
| directory in application/packages.
|
*/
'packages' => array(),
/*
|--------------------------------------------------------------------------
| Application Key
|--------------------------------------------------------------------------
|
| Your application key should be a 32 character string that is totally
| random and secret. This key is used by the encryption class to generate
| secure, encrypted strings.
|
*/
'key' => '',
);
\ No newline at end of file
...@@ -11,20 +11,13 @@ ...@@ -11,20 +11,13 @@
// -------------------------------------------------------------- // --------------------------------------------------------------
// The active modules for this Laravel installation. // The active modules for this Laravel installation.
// -------------------------------------------------------------- // --------------------------------------------------------------
$active = array( $active = array();
'application' => 'application',
);
// -------------------------------------------------------------- // --------------------------------------------------------------
// The path to the Laravel directory. // The path to the Laravel directory.
// -------------------------------------------------------------- // --------------------------------------------------------------
$system = '../laravel'; $system = '../laravel';
// --------------------------------------------------------------
// The path to the configuration directory.
// --------------------------------------------------------------
$config = '../config';
// -------------------------------------------------------------- // --------------------------------------------------------------
// The path to the packages directory. // The path to the packages directory.
// -------------------------------------------------------------- // --------------------------------------------------------------
......
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