2.0 modular refactoring.
This commit is contained in:
parent
4569ebec46
commit
d9f2ba84c9
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
return array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Class Aliases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here, you can specify any class aliases that you would like registered
|
||||
| when Laravel loads. Aliases are lazy-loaded, so add as many as you want.
|
||||
|
|
||||
| Aliases make it more convenient to use namespaced classes. Instead of
|
||||
| referring to the class using its full namespace, you may simply use
|
||||
| the alias defined here.
|
||||
|
|
||||
| We have already aliased common Laravel classes to make your life easier.
|
||||
|
|
||||
*/
|
||||
|
||||
'Asset' => 'Laravel\\Asset',
|
||||
'Auth' => 'Laravel\\Auth',
|
||||
'Benchmark' => 'Laravel\\Benchmark',
|
||||
'Cache' => 'Laravel\\Cache',
|
||||
'Config' => 'Laravel\\Config',
|
||||
'Cookie' => 'Laravel\\Cookie',
|
||||
'Crypter' => 'Laravel\\Crypter',
|
||||
'DB' => 'Laravel\\DB',
|
||||
'Eloquent' => 'Laravel\\DB\\Eloquent\\Model',
|
||||
'File' => 'Laravel\\File',
|
||||
'Form' => 'Laravel\\Form',
|
||||
'Hash' => 'Laravel\\Hash',
|
||||
'HTML' => 'Laravel\\HTML',
|
||||
'Inflector' => 'Laravel\\Inflector',
|
||||
'Input' => 'Laravel\\Input',
|
||||
'Lang' => 'Laravel\\Lang',
|
||||
'Loader' => 'Laravel\\Loader',
|
||||
'Package' => 'Laravel\\Package',
|
||||
'URL' => 'Laravel\\URL',
|
||||
'Redirect' => 'Laravel\\Redirect',
|
||||
'Request' => 'Laravel\\Request',
|
||||
'Response' => 'Laravel\\Response',
|
||||
'Session' => 'Laravel\\Session',
|
||||
'Str' => 'Laravel\\Str',
|
||||
'Validator' => 'Laravel\\Validator',
|
||||
'View' => 'Laravel\\View',
|
||||
|
||||
);
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
return array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Class Aliases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here, you can specify any class aliases that you would like registered
|
||||
| when Laravel loads. Aliases are lazy-loaded, so add as many as you want.
|
||||
|
|
||||
| Aliases make it more convenient to use namespaced classes. Instead of
|
||||
| referring to the class using its full namespace, you may simply use
|
||||
| the alias defined here.
|
||||
|
|
||||
| We have already aliased common Laravel classes to make your life easier.
|
||||
|
|
||||
*/
|
||||
|
||||
'Asset' => 'Laravel\\Asset',
|
||||
'Auth' => 'Laravel\\Auth',
|
||||
'Benchmark' => 'Laravel\\Benchmark',
|
||||
'Cache' => 'Laravel\\Cache',
|
||||
'Config' => 'Laravel\\Config',
|
||||
'Cookie' => 'Laravel\\Cookie',
|
||||
'Crypter' => 'Laravel\\Crypter',
|
||||
'DB' => 'Laravel\\DB',
|
||||
'Eloquent' => 'Laravel\\DB\\Eloquent\\Model',
|
||||
'File' => 'Laravel\\File',
|
||||
'Form' => 'Laravel\\Form',
|
||||
'Hash' => 'Laravel\\Hash',
|
||||
'HTML' => 'Laravel\\HTML',
|
||||
'Inflector' => 'Laravel\\Inflector',
|
||||
'Input' => 'Laravel\\Input',
|
||||
'Lang' => 'Laravel\\Lang',
|
||||
'Loader' => 'Laravel\\Loader',
|
||||
'Package' => 'Laravel\\Package',
|
||||
'URL' => 'Laravel\\URL',
|
||||
'Redirect' => 'Laravel\\Redirect',
|
||||
'Request' => 'Laravel\\Request',
|
||||
'Response' => 'Laravel\\Response',
|
||||
'Session' => 'Laravel\\Session',
|
||||
'Str' => 'Laravel\\Str',
|
||||
'Validator' => 'Laravel\\Validator',
|
||||
'View' => 'Laravel\\View',
|
||||
|
||||
);
|
|
@ -67,14 +67,12 @@ public function get($language = null, $default = null)
|
|||
|
||||
list($module, $file, $line) = $this->parse($this->key, $language);
|
||||
|
||||
$this->load($module, $file, $language);
|
||||
|
||||
if ( ! isset(static::$lines[$module][$language.$file][$line]))
|
||||
if ( ! $this->load($module, $file, $language))
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -109,16 +107,22 @@ private function parse($key, $language)
|
|||
* @param string $module
|
||||
* @param string $file
|
||||
* @param string $language
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
private function load($module, $file, $language)
|
||||
{
|
||||
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 the core framework paths.
|
||||
// --------------------------------------------------------------
|
||||
define('BASE_PATH', realpath(str_replace('laravel', '', $system)).'/');
|
||||
define('CONFIG_PATH', realpath($config).'/');
|
||||
define('MODULE_PATH', realpath($modules).'/');
|
||||
define('PACKAGE_PATH', realpath($packages).'/');
|
||||
define('PUBLIC_PATH', realpath($public).'/');
|
||||
|
@ -22,16 +21,13 @@
|
|||
// Define various other framework paths.
|
||||
// --------------------------------------------------------------
|
||||
define('CACHE_PATH', STORAGE_PATH.'cache/');
|
||||
define('CONFIG_PATH', SYS_PATH.'config/');
|
||||
define('DATABASE_PATH', STORAGE_PATH.'db/');
|
||||
define('LANG_PATH', SYS_PATH.'lang/');
|
||||
define('SCRIPT_PATH', PUBLIC_PATH.'js/');
|
||||
define('SESSION_PATH', STORAGE_PATH.'sessions/');
|
||||
define('STYLE_PATH', PUBLIC_PATH.'css/');
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Define the default module.
|
||||
// --------------------------------------------------------------
|
||||
define('DEFAULT_MODULE', 'application');
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Load the classes used by the auto-loader.
|
||||
// --------------------------------------------------------------
|
||||
|
@ -40,13 +36,23 @@
|
|||
require SYS_PATH.'module'.EXT;
|
||||
require SYS_PATH.'arr'.EXT;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Define the default module.
|
||||
// --------------------------------------------------------------
|
||||
define('DEFAULT_MODULE', 'application');
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Register the active modules.
|
||||
// --------------------------------------------------------------
|
||||
Module::$modules = $active;
|
||||
Module::$modules = array_merge(array('application' => 'application'), $active);
|
||||
|
||||
unset($active);
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Define the default module path.
|
||||
// --------------------------------------------------------------
|
||||
define('DEFAULT_MODULE_PATH', Module::path(DEFAULT_MODULE));
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Register the auto-loader.
|
||||
// --------------------------------------------------------------
|
||||
|
@ -142,6 +148,11 @@
|
|||
// --------------------------------------------------------------
|
||||
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.
|
||||
// --------------------------------------------------------------
|
||||
|
|
|
@ -43,9 +43,10 @@ public static function path($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].'/';
|
||||
|
||||
return static::$paths[$module] = $path;
|
||||
if (array_key_exists($module, static::$modules))
|
||||
{
|
||||
return static::$paths[$module] = MODULE_PATH.static::$modules[$module].'/';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
<?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' => '',
|
||||
|
||||
);
|
|
@ -11,20 +11,13 @@
|
|||
// --------------------------------------------------------------
|
||||
// The active modules for this Laravel installation.
|
||||
// --------------------------------------------------------------
|
||||
$active = array(
|
||||
'application' => 'application',
|
||||
);
|
||||
$active = array();
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// The path to the Laravel directory.
|
||||
// --------------------------------------------------------------
|
||||
$system = '../laravel';
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// The path to the configuration directory.
|
||||
// --------------------------------------------------------------
|
||||
$config = '../config';
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// The path to the packages directory.
|
||||
// --------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue