more ioc refactoring.
This commit is contained in:
parent
0ef96fb8d0
commit
c200f3eb1e
|
@ -29,7 +29,7 @@
|
||||||
'Download' => 'Laravel\\Download',
|
'Download' => 'Laravel\\Download',
|
||||||
'Eloquent' => 'Laravel\\Database\\Eloquent\\Model',
|
'Eloquent' => 'Laravel\\Database\\Eloquent\\Model',
|
||||||
'Error' => 'Laravel\\Error',
|
'Error' => 'Laravel\\Error',
|
||||||
'File' => 'Laravel\\File_Facade',
|
'File' => 'Laravel\\File',
|
||||||
'Form' => 'Laravel\\Form',
|
'Form' => 'Laravel\\Form',
|
||||||
'Hasher' => 'Laravel\\Security\\Hasher',
|
'Hasher' => 'Laravel\\Security\\Hasher',
|
||||||
'HTML' => 'Laravel\\HTML',
|
'HTML' => 'Laravel\\HTML',
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// 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;
|
||||||
|
|
|
@ -5,7 +5,7 @@ class File extends Driver {
|
||||||
/**
|
/**
|
||||||
* The file engine instance.
|
* The file engine instance.
|
||||||
*
|
*
|
||||||
* @var Laravel\File_Engine
|
* @var Laravel\File
|
||||||
*/
|
*/
|
||||||
private $file;
|
private $file;
|
||||||
|
|
||||||
|
@ -19,11 +19,11 @@ class File extends Driver {
|
||||||
/**
|
/**
|
||||||
* Create a new File cache driver instance.
|
* Create a new File cache driver instance.
|
||||||
*
|
*
|
||||||
* @param Laravel\File_Engine $file
|
* @param Laravel\File $file
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(\Laravel\File_Engine $file, $path)
|
public function __construct(\Laravel\File $file, $path)
|
||||||
{
|
{
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
|
@ -32,11 +32,6 @@ public function __construct(\Laravel\File_Engine $file, $path)
|
||||||
/**
|
/**
|
||||||
* Determine if an item exists in the cache.
|
* Determine if an item exists in the cache.
|
||||||
*
|
*
|
||||||
* <code>
|
|
||||||
* // Determine if the "name" item exists in the cache
|
|
||||||
* $exists = Cache::driver()->has('name');
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@ -66,11 +61,6 @@ protected function retrieve($key)
|
||||||
/**
|
/**
|
||||||
* Write an item to the cache for a given number of minutes.
|
* Write an item to the cache for a given number of minutes.
|
||||||
*
|
*
|
||||||
* <code>
|
|
||||||
* // Write the "name" item to the cache for 30 minutes
|
|
||||||
* Cache::driver()->put('name', 'Fred', 30);
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @param int $minutes
|
* @param int $minutes
|
||||||
|
|
|
@ -43,16 +43,12 @@
|
||||||
|
|
||||||
'laravel.file' => array('singleton' => true, 'resolver' => function($container)
|
'laravel.file' => array('singleton' => true, 'resolver' => function($container)
|
||||||
{
|
{
|
||||||
require_once SYS_PATH.'file'.EXT;
|
|
||||||
|
|
||||||
return new File($container->resolve('laravel.config')->get('mimes'));
|
return new File($container->resolve('laravel.config')->get('mimes'));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
||||||
'laravel.input' => array('singleton' => true, 'resolver' => function($container)
|
'laravel.input' => array('singleton' => true, 'resolver' => function($container)
|
||||||
{
|
{
|
||||||
require_once SYS_PATH.'input'.EXT;
|
|
||||||
|
|
||||||
$application = $container->resolve('laravel.application');
|
$application = $container->resolve('laravel.application');
|
||||||
|
|
||||||
$input = array();
|
$input = array();
|
||||||
|
@ -70,15 +66,13 @@
|
||||||
($application->request->spoofed()) ? $input = $_POST : parse_str(file_get_contents('php://input'), $input);
|
($application->request->spoofed()) ? $input = $_POST : parse_str(file_get_contents('php://input'), $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Input_Engine($input, $_FILES, $container->resolve('laravel.cookie'));
|
return new Input($input, $_FILES, $container->resolve('laravel.cookie'));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
||||||
'laravel.lang' => array('singleton' => true, 'resolver' => function($container)
|
'laravel.lang' => array('singleton' => true, 'resolver' => function($container)
|
||||||
{
|
{
|
||||||
require_once SYS_PATH.'lang'.EXT;
|
return new Lang($container->resolve('laravel.config')->get('application.language'), array(SYS_LANG_PATH, LANG_PATH));
|
||||||
|
|
||||||
return new Lang_Engine($container->resolve('laravel.config')->get('application.language'), array(SYS_LANG_PATH, LANG_PATH));
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,23 +86,19 @@
|
||||||
|
|
||||||
'laravel.package' => array('singleton' => true, 'resolver' => function()
|
'laravel.package' => array('singleton' => true, 'resolver' => function()
|
||||||
{
|
{
|
||||||
return new Package_Engine(PACKAGE_PATH);
|
return new Package(PACKAGE_PATH);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
||||||
'laravel.redirect' => array('singleton' => true, 'resolver' => function($container)
|
'laravel.redirect' => array('singleton' => true, 'resolver' => function($container)
|
||||||
{
|
{
|
||||||
require_once SYS_PATH.'redirect'.EXT;
|
return new Redirect($container->resolve('laravel.url'));
|
||||||
|
|
||||||
return new Redirect_Engine($container->resolve('laravel.url'));
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
||||||
'laravel.request' => array('singleton' => true, 'resolver' => function($container)
|
'laravel.request' => array('singleton' => true, 'resolver' => function($container)
|
||||||
{
|
{
|
||||||
require_once SYS_PATH.'request'.EXT;
|
return new Request($_SERVER, $container->resolve('laravel.config')->get('application.url'));
|
||||||
|
|
||||||
return new Request_Engine($_SERVER, $container->resolve('laravel.config')->get('application.url'));
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,15 +130,13 @@
|
||||||
|
|
||||||
'laravel.url' => array('singleton' => true, 'resolver' => function($container)
|
'laravel.url' => array('singleton' => true, 'resolver' => function($container)
|
||||||
{
|
{
|
||||||
require_once SYS_PATH.'url'.EXT;
|
|
||||||
|
|
||||||
list($request, $base, $index) = array(
|
list($request, $base, $index) = array(
|
||||||
$container->resolve('laravel.request'),
|
$container->resolve('laravel.request'),
|
||||||
$container->resolve('laravel.config')->get('application.url'),
|
$container->resolve('laravel.config')->get('application.url'),
|
||||||
$container->resolve('laravel.config')->get('application.index'),
|
$container->resolve('laravel.config')->get('application.index'),
|
||||||
);
|
);
|
||||||
|
|
||||||
return new URL_Engine($container->resolve('laravel.router'), $base, $index, $request->secure());
|
return new URL($container->resolve('laravel.router'), $base, $index, $request->secure());
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Download_Facade extends Facade { public static $resolve = 'download'; }
|
|
||||||
|
|
||||||
class Download extends Response {
|
class Download extends Response {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?php namespace Laravel;
|
|
||||||
|
|
||||||
abstract class Facade {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic Method that allows the calling of a class staticly. This provides a convenient API
|
|
||||||
* while still maintaining the benefits of dependency injection and testability of the class.
|
|
||||||
*
|
|
||||||
* Each facade has a "resolve" property that informs the base class of what it needs to resolve
|
|
||||||
* our of the IoC container each time an operation is called on the facade.
|
|
||||||
*/
|
|
||||||
public static function __callStatic($method, $parameters)
|
|
||||||
{
|
|
||||||
return call_user_func_array(array(IoC::container()->resolve('laravel.'.static::$resolve), $method), $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class File_Facade extends Facade { public static $resolve = 'file'; }
|
|
||||||
|
|
||||||
class File {
|
class File {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,7 +10,7 @@ class File {
|
||||||
private $mimes;
|
private $mimes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new file manager instance.
|
* Create a new file engine instance.
|
||||||
*
|
*
|
||||||
* @param array $mimes
|
* @param array $mimes
|
||||||
* @return void
|
* @return void
|
||||||
|
|
|
@ -116,14 +116,6 @@ class Inflector {
|
||||||
/**
|
/**
|
||||||
* Get the plural form of a word if the specified count is greater than one.
|
* Get the plural form of a word if the specified count is greater than one.
|
||||||
*
|
*
|
||||||
* <code>
|
|
||||||
* // Returns "friend"
|
|
||||||
* Inflector::plural_if('friend', 1);
|
|
||||||
*
|
|
||||||
* // Returns "friends"
|
|
||||||
* Inflector::plural_if('friend', 2);
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param int $count
|
* @param int $count
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -136,14 +128,6 @@ public static function plural_if($value, $count)
|
||||||
/**
|
/**
|
||||||
* Convert a word to its plural form.
|
* Convert a word to its plural form.
|
||||||
*
|
*
|
||||||
* <code>
|
|
||||||
* // Returns "friends"
|
|
||||||
* Inflector::plural('friend');
|
|
||||||
*
|
|
||||||
* // Returns "children"
|
|
||||||
* Inflector::plural('child');
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -157,14 +141,6 @@ public static function plural($value)
|
||||||
/**
|
/**
|
||||||
* Convert a word to its singular form.
|
* Convert a word to its singular form.
|
||||||
*
|
*
|
||||||
* <code>
|
|
||||||
* // Returns "friend"
|
|
||||||
* Inflector::singular('friends');
|
|
||||||
*
|
|
||||||
* // Returns "child"
|
|
||||||
* Inflector::singular('children');
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Input extends Facade { public static $resolve = 'input'; }
|
class Input {
|
||||||
|
|
||||||
class Input_Engine {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The applicable input for the request.
|
* The applicable input for the request.
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Lang extends Facade { public static $resolve = 'lang'; }
|
class Lang {
|
||||||
|
|
||||||
class Lang_Engine {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All of the loaded language lines.
|
* All of the loaded language lines.
|
||||||
|
|
|
@ -47,7 +47,9 @@
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
if ($application->config->get('session.driver') !== '')
|
if ($application->config->get('session.driver') !== '')
|
||||||
{
|
{
|
||||||
$application->session->start($application->input->cookies->get('laravel_session'), $application->config->get('session.lifetime'));
|
$cookie = $application->input->cookies->get('laravel_session');
|
||||||
|
|
||||||
|
$application->session->start($cookie, $application->config->get('session.lifetime'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
|
|
|
@ -40,8 +40,6 @@ public function load($class)
|
||||||
{
|
{
|
||||||
$file = strtolower(str_replace('\\', '/', $class));
|
$file = strtolower(str_replace('\\', '/', $class));
|
||||||
|
|
||||||
if (strpos($file, 'laravel') !== false) $file = str_replace('_facade', '', $file);
|
|
||||||
|
|
||||||
if (array_key_exists($class, $this->aliases))
|
if (array_key_exists($class, $this->aliases))
|
||||||
{
|
{
|
||||||
return class_alias($this->aliases[$class], $class);
|
return class_alias($this->aliases[$class], $class);
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Package extends Facade { public static $resolve = 'package'; }
|
class Package {
|
||||||
|
|
||||||
class Package_Engine {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All of the loaded packages.
|
* All of the loaded packages.
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Redirect extends Facade { public static $resolve = 'redirect'; }
|
class Redirect extends Response {
|
||||||
|
|
||||||
class Redirect_Engine extends Response {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL generator instance.
|
* The URL generator instance.
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Request extends Facade { public static $resolve = 'request'; }
|
class Request {
|
||||||
|
|
||||||
class Request_Engine {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The $_SERVER array for the request.
|
* The $_SERVER array for the request.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php namespace Laravel\Routing;
|
<?php namespace Laravel\Routing;
|
||||||
|
|
||||||
use Laravel\Request_Engine;
|
use Laravel\Request;
|
||||||
|
|
||||||
class Router {
|
class Router {
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class Router {
|
||||||
/**
|
/**
|
||||||
* The current request instance.
|
* The current request instance.
|
||||||
*
|
*
|
||||||
* @var Request_Engine
|
* @var Request
|
||||||
*/
|
*/
|
||||||
protected $request;
|
protected $request;
|
||||||
|
|
||||||
|
@ -35,11 +35,11 @@ class Router {
|
||||||
/**
|
/**
|
||||||
* Create a new router for a request method and URI.
|
* Create a new router for a request method and URI.
|
||||||
*
|
*
|
||||||
* @param Request_Engine $request
|
* @param Request $request
|
||||||
* @param array $routes
|
* @param array $routes
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(Request_Engine $request, $routes, $controller_path)
|
public function __construct(Request $request, $routes, $controller_path)
|
||||||
{
|
{
|
||||||
$this->routes = $routes;
|
$this->routes = $routes;
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
|
|
|
@ -5,7 +5,7 @@ class File extends Driver implements Sweeper {
|
||||||
/**
|
/**
|
||||||
* The file engine instance.
|
* The file engine instance.
|
||||||
*
|
*
|
||||||
* @var Laravel\File_Engine
|
* @var Laravel\File
|
||||||
*/
|
*/
|
||||||
private $file;
|
private $file;
|
||||||
|
|
||||||
|
@ -19,11 +19,11 @@ class File extends Driver implements Sweeper {
|
||||||
/**
|
/**
|
||||||
* Create a new File session driver instance.
|
* Create a new File session driver instance.
|
||||||
*
|
*
|
||||||
* @param Laravel\File_Engine $file
|
* @param Laravel\File $file
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(\Laravel\File_Engine $file, $path)
|
public function __construct(\Laravel\File $file, $path)
|
||||||
{
|
{
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<?php namespace Laravel;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class URL extends Facade { public static $resolve = 'url'; }
|
class URL {
|
||||||
|
|
||||||
class URL_Engine {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new URL writer instance.
|
* Create a new URL writer instance.
|
||||||
|
|
Loading…
Reference in New Issue