diff --git a/application/config/aliases.php b/application/config/aliases.php index 6442e1b3..1b74b916 100644 --- a/application/config/aliases.php +++ b/application/config/aliases.php @@ -22,30 +22,30 @@ 'Auth' => 'Laravel\\Security\\Authenticator', 'Benchmark' => 'Laravel\\Benchmark', 'Cache' => 'Laravel\\Cache\\Manager', - 'Config' => 'Laravel\\Config', - 'Cookie' => 'Laravel\\Cookie', + 'Config' => 'Laravel\\Config_Facade', + 'Cookie' => 'Laravel\\Cookie_Facade', 'Crypter' => 'Laravel\\Security\\Crypter', 'DB' => 'Laravel\\Database\\Manager', - 'Download' => 'Laravel\\Download', + 'Download' => 'Laravel\\Download_Facade', 'Eloquent' => 'Laravel\\Database\\Eloquent\\Model', 'Error' => 'Laravel\\Error', - 'File' => 'Laravel\\File', - 'Form' => 'Laravel\\Form', + 'File' => 'Laravel\\File_Facade', + 'Form' => 'Laravel\\Form_Facade', 'Hasher' => 'Laravel\\Security\\Hasher', - 'HTML' => 'Laravel\\HTML', + 'HTML' => 'Laravel\\HTML_Facade', 'Inflector' => 'Laravel\\Inflector', - 'Input' => 'Laravel\\Input', + 'Input' => 'Laravel\\Input_Facade', 'IoC' => 'Laravel\\IoC', - 'Lang' => 'Laravel\\Lang', - 'Loader' => 'Laravel\\Loader', - 'Package' => 'Laravel\\Package', - 'URL' => 'Laravel\\URL', - 'Redirect' => 'Laravel\\Redirect', - 'Request' => 'Laravel\\Request', - 'Response' => 'Laravel\\Response', + 'Lang' => 'Laravel\\Lang_Facade', + 'Loader' => 'Laravel\\Loader_Facade', + 'Package' => 'Laravel\\Package_Facade', + 'URL' => 'Laravel\\URL_Facade', + 'Redirect' => 'Laravel\\Redirect_Facade', + 'Request' => 'Laravel\\Request_Facade', + 'Response' => 'Laravel\\Response_Facade', 'Session' => 'Laravel\\Session\\Manager', 'Str' => 'Laravel\\Str', 'Validator' => 'Laravel\\Validation\\Validator', - 'View' => 'Laravel\\View', + 'View' => 'Laravel\\View_Facade', ); \ No newline at end of file diff --git a/application/routes.php b/application/routes.php index 6d460842..3dee548d 100644 --- a/application/routes.php +++ b/application/routes.php @@ -39,7 +39,7 @@ 'GET /' => function($laravel) { - return $laravel->view->make('home.index'); + return View::make('home.index'); }, ); \ No newline at end of file diff --git a/laravel/bootstrap.php b/laravel/bootstrap.php index e9f650ad..bd233dfa 100644 --- a/laravel/bootstrap.php +++ b/laravel/bootstrap.php @@ -42,6 +42,7 @@ // -------------------------------------------------------------- // Load the configuration manager. // -------------------------------------------------------------- +require SYS_PATH.'facade'.EXT; require SYS_PATH.'loader'.EXT; require SYS_PATH.'config'.EXT; require SYS_PATH.'arr'.EXT; diff --git a/laravel/config.php b/laravel/config.php index 3a7d78c7..53b6d37d 100644 --- a/laravel/config.php +++ b/laravel/config.php @@ -1,5 +1,7 @@ array('resolver' => function($container) + 'laravel.form' => array('singleton' => true, 'resolver' => function($container) { list($request, $html, $url) = array( $container->resolve('laravel.request'), @@ -79,7 +79,7 @@ }), - 'laravel.html' => array('resolver' => function($container) + 'laravel.html' => array('singleton' => true, 'resolver' => function($container) { return new HTML($container->resolve('laravel.url'), $container->resolve('laravel.config')->get('application.encoding')); }), @@ -110,7 +110,9 @@ 'laravel.lang' => array('singleton' => true, 'resolver' => function($container) { - return new Lang($container->resolve('laravel.config')->get('application.language'), array(SYS_LANG_PATH, LANG_PATH)); + require_once SYS_PATH.'lang'.EXT; + + return new Lang_Factory($container->resolve('laravel.config'), array(SYS_LANG_PATH, LANG_PATH)); }), diff --git a/laravel/cookie.php b/laravel/cookie.php index 3b7a3be0..d3732099 100644 --- a/laravel/cookie.php +++ b/laravel/cookie.php @@ -1,5 +1,7 @@ resolve('laravel.'.static::$resolve), $method), $parameters); + } + +} \ No newline at end of file diff --git a/laravel/file.php b/laravel/file.php index 2f39e81a..6a67ec92 100644 --- a/laravel/file.php +++ b/laravel/file.php @@ -1,5 +1,7 @@ paths = $paths; + $this->config = $config; + } + + /** + * Begin retrieving a language line. + * + * @param string $key + * @param array $replacements + * @return Lang + */ + public function line($key, $replacements = array()) + { + return new Lang($key, $replacements, $this->config->get('application.language'), $this->paths); + } + +} + class Lang { /** @@ -9,21 +54,7 @@ class Lang { * * @var array */ - private $lines = array(); - - /** - * The default language being used by the application. - * - * @var string - */ - private $language; - - /** - * The paths containing the language files. - * - * @var array - */ - private $paths; + private static $lines = array(); /** * The key of the language line being retrieved. @@ -40,45 +71,34 @@ class Lang { private $replacements; /** - * The language of the line being retrieved. - * - * This is set to the default language when a new line is requested. - * However, it may be changed using the "in" method. + * The default language being used by the application. * * @var string */ - private $line_language; + private $language; + + /** + * The paths containing the language files. + * + * @var array + */ + private $paths; /** * Create a new Lang instance. * + * @param string $key + * @param array $replacements * @param string $language * @param array $paths * @return void */ - public function __construct($language, $paths) - { - $this->paths = $paths; - $this->language = $language; - } - - /** - * Begin retrieving a new language line. - * - * Language lines are retrieved using "dot" notation. So, asking for the "messages.required" langauge - * line would return the "required" line from the "messages" language file. - * - * @param string $key - * @param array $replacements - * @return Lang - */ - public function line($key, $replacements = array()) + public function __construct($key, $replacements, $language, $paths) { $this->key = $key; + $this->paths = $paths; + $this->language = $language; $this->replacements = $replacements; - $this->line_language = $this->language; - - return $this; } /** @@ -98,7 +118,7 @@ public function get($default = null) return ($default instanceof \Closure) ? call_user_func($default) : $default; } - $line = Arr::get($this->lines[$this->line_language.$file], $line, $default); + $line = Arr::get(static::$lines[$this->language.$file], $line, $default); foreach ($this->replacements as $key => $value) { @@ -138,13 +158,13 @@ private function parse($key) */ private function load($file) { - if (isset($this->lines[$this->line_language.$file])) return; + if (isset(static::$lines[$this->language.$file])) return; $language = array(); foreach ($this->paths as $directory) { - if (file_exists($path = $directory.$this->line_language.'/'.$file.EXT)) + if (file_exists($path = $directory.$this->language.'/'.$file.EXT)) { $language = array_merge($language, require $path); } @@ -152,10 +172,10 @@ private function load($file) if (count($language) > 0) { - $this->lines[$this->line_language.$file] = $language; + static::$lines[$this->language.$file] = $language; } - return isset($this->lines[$this->line_language.$file]); + return isset(static::$lines[$this->language.$file]); } /** @@ -168,7 +188,7 @@ private function load($file) */ public function in($language) { - $this->line_language = $line_language; + $this->language = $language; return $this; } diff --git a/laravel/loader.php b/laravel/loader.php index 9e7481bb..9ef61813 100644 --- a/laravel/loader.php +++ b/laravel/loader.php @@ -1,5 +1,7 @@ aliases)) { diff --git a/laravel/package.php b/laravel/package.php index 9839b2f6..01c7c4b0 100644 --- a/laravel/package.php +++ b/laravel/package.php @@ -1,5 +1,7 @@