more ioc refactoring.
This commit is contained in:
parent
0ef96fb8d0
commit
c200f3eb1e
|
@ -29,7 +29,7 @@
|
|||
'Download' => 'Laravel\\Download',
|
||||
'Eloquent' => 'Laravel\\Database\\Eloquent\\Model',
|
||||
'Error' => 'Laravel\\Error',
|
||||
'File' => 'Laravel\\File_Facade',
|
||||
'File' => 'Laravel\\File',
|
||||
'Form' => 'Laravel\\Form',
|
||||
'Hasher' => 'Laravel\\Security\\Hasher',
|
||||
'HTML' => 'Laravel\\HTML',
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
// --------------------------------------------------------------
|
||||
// Load the configuration manager.
|
||||
// --------------------------------------------------------------
|
||||
require SYS_PATH.'facade'.EXT;
|
||||
require SYS_PATH.'loader'.EXT;
|
||||
require SYS_PATH.'config'.EXT;
|
||||
require SYS_PATH.'arr'.EXT;
|
||||
|
|
|
@ -5,7 +5,7 @@ class File extends Driver {
|
|||
/**
|
||||
* The file engine instance.
|
||||
*
|
||||
* @var Laravel\File_Engine
|
||||
* @var Laravel\File
|
||||
*/
|
||||
private $file;
|
||||
|
||||
|
@ -19,11 +19,11 @@ class File extends Driver {
|
|||
/**
|
||||
* Create a new File cache driver instance.
|
||||
*
|
||||
* @param Laravel\File_Engine $file
|
||||
* @param Laravel\File $file
|
||||
* @param string $path
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(\Laravel\File_Engine $file, $path)
|
||||
public function __construct(\Laravel\File $file, $path)
|
||||
{
|
||||
$this->file = $file;
|
||||
$this->path = $path;
|
||||
|
@ -32,11 +32,6 @@ public function __construct(\Laravel\File_Engine $file, $path)
|
|||
/**
|
||||
* 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
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -66,11 +61,6 @@ protected function retrieve($key)
|
|||
/**
|
||||
* 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 mixed $value
|
||||
* @param int $minutes
|
||||
|
|
|
@ -43,16 +43,12 @@
|
|||
|
||||
'laravel.file' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'file'.EXT;
|
||||
|
||||
return new File($container->resolve('laravel.config')->get('mimes'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.input' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'input'.EXT;
|
||||
|
||||
$application = $container->resolve('laravel.application');
|
||||
|
||||
$input = array();
|
||||
|
@ -70,15 +66,13 @@
|
|||
($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)
|
||||
{
|
||||
require_once SYS_PATH.'lang'.EXT;
|
||||
|
||||
return new Lang_Engine($container->resolve('laravel.config')->get('application.language'), array(SYS_LANG_PATH, LANG_PATH));
|
||||
return new Lang($container->resolve('laravel.config')->get('application.language'), array(SYS_LANG_PATH, LANG_PATH));
|
||||
}),
|
||||
|
||||
|
||||
|
@ -92,23 +86,19 @@
|
|||
|
||||
'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)
|
||||
{
|
||||
require_once SYS_PATH.'redirect'.EXT;
|
||||
|
||||
return new Redirect_Engine($container->resolve('laravel.url'));
|
||||
return new Redirect($container->resolve('laravel.url'));
|
||||
}),
|
||||
|
||||
|
||||
'laravel.request' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'request'.EXT;
|
||||
|
||||
return new Request_Engine($_SERVER, $container->resolve('laravel.config')->get('application.url'));
|
||||
return new Request($_SERVER, $container->resolve('laravel.config')->get('application.url'));
|
||||
}),
|
||||
|
||||
|
||||
|
@ -140,15 +130,13 @@
|
|||
|
||||
'laravel.url' => array('singleton' => true, 'resolver' => function($container)
|
||||
{
|
||||
require_once SYS_PATH.'url'.EXT;
|
||||
|
||||
list($request, $base, $index) = array(
|
||||
$container->resolve('laravel.request'),
|
||||
$container->resolve('laravel.config')->get('application.url'),
|
||||
$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;
|
||||
|
||||
class Download_Facade extends Facade { public static $resolve = 'download'; }
|
||||
|
||||
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;
|
||||
|
||||
class File_Facade extends Facade { public static $resolve = 'file'; }
|
||||
|
||||
class File {
|
||||
|
||||
/**
|
||||
|
@ -12,7 +10,7 @@ class File {
|
|||
private $mimes;
|
||||
|
||||
/**
|
||||
* Create a new file manager instance.
|
||||
* Create a new file engine instance.
|
||||
*
|
||||
* @param array $mimes
|
||||
* @return void
|
||||
|
|
|
@ -116,14 +116,6 @@ class Inflector {
|
|||
/**
|
||||
* 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 int $count
|
||||
* @return string
|
||||
|
@ -136,14 +128,6 @@ public static function plural_if($value, $count)
|
|||
/**
|
||||
* Convert a word to its plural form.
|
||||
*
|
||||
* <code>
|
||||
* // Returns "friends"
|
||||
* Inflector::plural('friend');
|
||||
*
|
||||
* // Returns "children"
|
||||
* Inflector::plural('child');
|
||||
* </code>
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
|
@ -157,14 +141,6 @@ public static function plural($value)
|
|||
/**
|
||||
* Convert a word to its singular form.
|
||||
*
|
||||
* <code>
|
||||
* // Returns "friend"
|
||||
* Inflector::singular('friends');
|
||||
*
|
||||
* // Returns "child"
|
||||
* Inflector::singular('children');
|
||||
* </code>
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?php namespace Laravel;
|
||||
|
||||
class Input extends Facade { public static $resolve = 'input'; }
|
||||
|
||||
class Input_Engine {
|
||||
class Input {
|
||||
|
||||
/**
|
||||
* The applicable input for the request.
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?php namespace Laravel;
|
||||
|
||||
class Lang extends Facade { public static $resolve = 'lang'; }
|
||||
|
||||
class Lang_Engine {
|
||||
class Lang {
|
||||
|
||||
/**
|
||||
* All of the loaded language lines.
|
||||
|
|
|
@ -47,7 +47,9 @@
|
|||
// --------------------------------------------------------------
|
||||
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));
|
||||
|
||||
if (strpos($file, 'laravel') !== false) $file = str_replace('_facade', '', $file);
|
||||
|
||||
if (array_key_exists($class, $this->aliases))
|
||||
{
|
||||
return class_alias($this->aliases[$class], $class);
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?php namespace Laravel;
|
||||
|
||||
class Package extends Facade { public static $resolve = 'package'; }
|
||||
|
||||
class Package_Engine {
|
||||
class Package {
|
||||
|
||||
/**
|
||||
* All of the loaded packages.
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?php namespace Laravel;
|
||||
|
||||
class Redirect extends Facade { public static $resolve = 'redirect'; }
|
||||
|
||||
class Redirect_Engine extends Response {
|
||||
class Redirect extends Response {
|
||||
|
||||
/**
|
||||
* The URL generator instance.
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?php namespace Laravel;
|
||||
|
||||
class Request extends Facade { public static $resolve = 'request'; }
|
||||
|
||||
class Request_Engine {
|
||||
class Request {
|
||||
|
||||
/**
|
||||
* The $_SERVER array for the request.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Laravel\Routing;
|
||||
|
||||
use Laravel\Request_Engine;
|
||||
use Laravel\Request;
|
||||
|
||||
class Router {
|
||||
|
||||
|
@ -14,7 +14,7 @@ class Router {
|
|||
/**
|
||||
* The current request instance.
|
||||
*
|
||||
* @var Request_Engine
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
|
@ -35,11 +35,11 @@ class Router {
|
|||
/**
|
||||
* Create a new router for a request method and URI.
|
||||
*
|
||||
* @param Request_Engine $request
|
||||
* @param Request $request
|
||||
* @param array $routes
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Request_Engine $request, $routes, $controller_path)
|
||||
public function __construct(Request $request, $routes, $controller_path)
|
||||
{
|
||||
$this->routes = $routes;
|
||||
$this->request = $request;
|
||||
|
|
|
@ -5,7 +5,7 @@ class File extends Driver implements Sweeper {
|
|||
/**
|
||||
* The file engine instance.
|
||||
*
|
||||
* @var Laravel\File_Engine
|
||||
* @var Laravel\File
|
||||
*/
|
||||
private $file;
|
||||
|
||||
|
@ -19,11 +19,11 @@ class File extends Driver implements Sweeper {
|
|||
/**
|
||||
* Create a new File session driver instance.
|
||||
*
|
||||
* @param Laravel\File_Engine $file
|
||||
* @param Laravel\File $file
|
||||
* @param string $path
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(\Laravel\File_Engine $file, $path)
|
||||
public function __construct(\Laravel\File $file, $path)
|
||||
{
|
||||
$this->file = $file;
|
||||
$this->path = $path;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?php namespace Laravel;
|
||||
|
||||
class URL extends Facade { public static $resolve = 'url'; }
|
||||
|
||||
class URL_Engine {
|
||||
class URL {
|
||||
|
||||
/**
|
||||
* Create a new URL writer instance.
|
||||
|
|
Loading…
Reference in New Issue