added facades for core classes.
This commit is contained in:
parent
86da3af7a1
commit
31e2c1c49e
|
@ -22,30 +22,30 @@
|
||||||
'Auth' => 'Laravel\\Security\\Authenticator',
|
'Auth' => 'Laravel\\Security\\Authenticator',
|
||||||
'Benchmark' => 'Laravel\\Benchmark',
|
'Benchmark' => 'Laravel\\Benchmark',
|
||||||
'Cache' => 'Laravel\\Cache\\Manager',
|
'Cache' => 'Laravel\\Cache\\Manager',
|
||||||
'Config' => 'Laravel\\Config',
|
'Config' => 'Laravel\\Config_Facade',
|
||||||
'Cookie' => 'Laravel\\Cookie',
|
'Cookie' => 'Laravel\\Cookie_Facade',
|
||||||
'Crypter' => 'Laravel\\Security\\Crypter',
|
'Crypter' => 'Laravel\\Security\\Crypter',
|
||||||
'DB' => 'Laravel\\Database\\Manager',
|
'DB' => 'Laravel\\Database\\Manager',
|
||||||
'Download' => 'Laravel\\Download',
|
'Download' => 'Laravel\\Download_Facade',
|
||||||
'Eloquent' => 'Laravel\\Database\\Eloquent\\Model',
|
'Eloquent' => 'Laravel\\Database\\Eloquent\\Model',
|
||||||
'Error' => 'Laravel\\Error',
|
'Error' => 'Laravel\\Error',
|
||||||
'File' => 'Laravel\\File',
|
'File' => 'Laravel\\File_Facade',
|
||||||
'Form' => 'Laravel\\Form',
|
'Form' => 'Laravel\\Form_Facade',
|
||||||
'Hasher' => 'Laravel\\Security\\Hasher',
|
'Hasher' => 'Laravel\\Security\\Hasher',
|
||||||
'HTML' => 'Laravel\\HTML',
|
'HTML' => 'Laravel\\HTML_Facade',
|
||||||
'Inflector' => 'Laravel\\Inflector',
|
'Inflector' => 'Laravel\\Inflector',
|
||||||
'Input' => 'Laravel\\Input',
|
'Input' => 'Laravel\\Input_Facade',
|
||||||
'IoC' => 'Laravel\\IoC',
|
'IoC' => 'Laravel\\IoC',
|
||||||
'Lang' => 'Laravel\\Lang',
|
'Lang' => 'Laravel\\Lang_Facade',
|
||||||
'Loader' => 'Laravel\\Loader',
|
'Loader' => 'Laravel\\Loader_Facade',
|
||||||
'Package' => 'Laravel\\Package',
|
'Package' => 'Laravel\\Package_Facade',
|
||||||
'URL' => 'Laravel\\URL',
|
'URL' => 'Laravel\\URL_Facade',
|
||||||
'Redirect' => 'Laravel\\Redirect',
|
'Redirect' => 'Laravel\\Redirect_Facade',
|
||||||
'Request' => 'Laravel\\Request',
|
'Request' => 'Laravel\\Request_Facade',
|
||||||
'Response' => 'Laravel\\Response',
|
'Response' => 'Laravel\\Response_Facade',
|
||||||
'Session' => 'Laravel\\Session\\Manager',
|
'Session' => 'Laravel\\Session\\Manager',
|
||||||
'Str' => 'Laravel\\Str',
|
'Str' => 'Laravel\\Str',
|
||||||
'Validator' => 'Laravel\\Validation\\Validator',
|
'Validator' => 'Laravel\\Validation\\Validator',
|
||||||
'View' => 'Laravel\\View',
|
'View' => 'Laravel\\View_Facade',
|
||||||
|
|
||||||
);
|
);
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
'GET /' => function($laravel)
|
'GET /' => function($laravel)
|
||||||
{
|
{
|
||||||
return $laravel->view->make('home.index');
|
return View::make('home.index');
|
||||||
},
|
},
|
||||||
|
|
||||||
);
|
);
|
|
@ -42,6 +42,7 @@
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Load the configuration manager.
|
// Load the configuration manager.
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
|
require SYS_PATH.'facade'.EXT;
|
||||||
require SYS_PATH.'loader'.EXT;
|
require SYS_PATH.'loader'.EXT;
|
||||||
require SYS_PATH.'config'.EXT;
|
require SYS_PATH.'config'.EXT;
|
||||||
require SYS_PATH.'arr'.EXT;
|
require SYS_PATH.'arr'.EXT;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Config_Facade extends Facade { public static $resolve = 'config'; }
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,14 +11,14 @@ class Config {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $items = array();
|
protected $items = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The paths containing the configuration files.
|
* The paths containing the configuration files.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $paths = array();
|
protected $paths = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new configuration manager instance.
|
* Create a new configuration manager instance.
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
||||||
'laravel.form' => array('resolver' => function($container)
|
'laravel.form' => array('singleton' => true, 'resolver' => function($container)
|
||||||
{
|
{
|
||||||
list($request, $html, $url) = array(
|
list($request, $html, $url) = array(
|
||||||
$container->resolve('laravel.request'),
|
$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'));
|
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)
|
'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));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Cookie_Facade extends Facade { public static $resolve = 'cookie'; }
|
||||||
|
|
||||||
class Cookie {
|
class Cookie {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Download_Facade extends Facade { public static $resolve = 'download'; }
|
||||||
|
|
||||||
class Download extends Response {
|
class Download extends Response {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
abstract class Facade {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic Method for passing methods to a class registered in the IoC container.
|
||||||
|
* This provides a convenient method of accessing functions on classes that
|
||||||
|
* could not otherwise be accessed staticly.
|
||||||
|
*/
|
||||||
|
public static function __callStatic($method, $parameters)
|
||||||
|
{
|
||||||
|
return call_user_func_array(array(IoC::container()->resolve('laravel.'.static::$resolve), $method), $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class File_Facade extends Facade { public static $resolve = 'file'; }
|
||||||
|
|
||||||
class File {
|
class File {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Form_Facade extends Facade { public static $resolve = 'form'; }
|
||||||
|
|
||||||
class Form {
|
class Form {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class HTML_Facade extends Facade { public static $resolve = 'html'; }
|
||||||
|
|
||||||
class HTML {
|
class HTML {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Input_Facade extends Facade { public static $resolve = 'input'; }
|
||||||
|
|
||||||
class Input {
|
class Input {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,7 +9,7 @@ class Input {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $input;
|
protected $input;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The $_GET array for the request.
|
* The $_GET array for the request.
|
||||||
|
|
112
laravel/lang.php
112
laravel/lang.php
|
@ -1,5 +1,50 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Lang_Facade extends Facade { public static $resolve = 'lang'; }
|
||||||
|
|
||||||
|
class Lang_Factory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The configuration manager instance.
|
||||||
|
*
|
||||||
|
* @var Config
|
||||||
|
*/
|
||||||
|
protected $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The paths containing the language files.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $paths;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new language factory instance.
|
||||||
|
*
|
||||||
|
* @param Config $config
|
||||||
|
* @param array $paths
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Config $config, $paths)
|
||||||
|
{
|
||||||
|
$this->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 {
|
class Lang {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,21 +54,7 @@ class Lang {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $lines = array();
|
private static $lines = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* The default language being used by the application.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $language;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The paths containing the language files.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $paths;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The key of the language line being retrieved.
|
* The key of the language line being retrieved.
|
||||||
|
@ -40,45 +71,34 @@ class Lang {
|
||||||
private $replacements;
|
private $replacements;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The language of the line being retrieved.
|
* The default language being used by the application.
|
||||||
*
|
|
||||||
* This is set to the default language when a new line is requested.
|
|
||||||
* However, it may be changed using the "in" method.
|
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $line_language;
|
private $language;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The paths containing the language files.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $paths;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Lang instance.
|
* Create a new Lang instance.
|
||||||
*
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param array $replacements
|
||||||
* @param string $language
|
* @param string $language
|
||||||
* @param array $paths
|
* @param array $paths
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct($language, $paths)
|
public function __construct($key, $replacements, $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())
|
|
||||||
{
|
{
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
|
$this->paths = $paths;
|
||||||
|
$this->language = $language;
|
||||||
$this->replacements = $replacements;
|
$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;
|
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)
|
foreach ($this->replacements as $key => $value)
|
||||||
{
|
{
|
||||||
|
@ -138,13 +158,13 @@ private function parse($key)
|
||||||
*/
|
*/
|
||||||
private function load($file)
|
private function load($file)
|
||||||
{
|
{
|
||||||
if (isset($this->lines[$this->line_language.$file])) return;
|
if (isset(static::$lines[$this->language.$file])) return;
|
||||||
|
|
||||||
$language = array();
|
$language = array();
|
||||||
|
|
||||||
foreach ($this->paths as $directory)
|
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);
|
$language = array_merge($language, require $path);
|
||||||
}
|
}
|
||||||
|
@ -152,10 +172,10 @@ private function load($file)
|
||||||
|
|
||||||
if (count($language) > 0)
|
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)
|
public function in($language)
|
||||||
{
|
{
|
||||||
$this->line_language = $line_language;
|
$this->language = $language;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Loader_Facade extends Facade { public static $resolve = 'loader'; }
|
||||||
|
|
||||||
class Loader {
|
class Loader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +40,7 @@ public function __construct($aliases, $paths)
|
||||||
*/
|
*/
|
||||||
public function load($class)
|
public function load($class)
|
||||||
{
|
{
|
||||||
$file = strtolower(str_replace('\\', '/', $class));
|
$file = strtolower(str_replace(array('\\', '_Facade'), array('/', ''), $class));
|
||||||
|
|
||||||
if (array_key_exists($class, $this->aliases))
|
if (array_key_exists($class, $this->aliases))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Package_Facade extends Facade { public static $resolve = 'package'; }
|
||||||
|
|
||||||
class Package {
|
class Package {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Redirect_Facade extends Facade { public static $resolve = 'redirect'; }
|
||||||
|
|
||||||
class Redirect extends Response {
|
class Redirect extends Response {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Request_Facade extends Facade { public static $resolve = 'request'; }
|
||||||
|
|
||||||
class Request {
|
class Request {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Response_Facade extends Facade { public static $resolve = 'response'; }
|
||||||
|
|
||||||
class Response_Factory {
|
class Response_Factory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class URL_Facade extends Facade { public static $resolve = 'url'; }
|
||||||
|
|
||||||
class URL {
|
class URL {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class View_Facade extends Facade { public static $resolve = 'view'; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The view composer class is responsible for calling the composer on a view and
|
* The view composer class is responsible for calling the composer on a view and
|
||||||
* searching through the view composers for a given view name. It is injected
|
* searching through the view composers for a given view name. It is injected
|
||||||
|
|
Loading…
Reference in New Issue