Commit c200f3eb authored by Taylor Otwell's avatar Taylor Otwell

more ioc refactoring.

parent 0ef96fb8
...@@ -29,7 +29,7 @@ return array( ...@@ -29,7 +29,7 @@ return array(
'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 @@ $application = new Application; ...@@ -42,7 +42,6 @@ $application = new Application;
// -------------------------------------------------------------- // --------------------------------------------------------------
// 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 { ...@@ -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 { ...@@ -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 @@ class File extends Driver { ...@@ -32,11 +32,6 @@ class File extends Driver {
/** /**
* 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 @@ class File extends Driver { ...@@ -66,11 +61,6 @@ class File extends Driver {
/** /**
* 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 @@ return array( ...@@ -43,16 +43,12 @@ return array(
'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 @@ return array( ...@@ -70,15 +66,13 @@ return array(
($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 @@ return array( ...@@ -92,23 +86,19 @@ return array(
'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 @@ return array( ...@@ -140,15 +130,13 @@ return array(
'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());
}), }),
......
<?php namespace Laravel; <?php namespace Laravel;
class Download_Facade extends Facade { public static $resolve = 'download'; }
class Download extends Response { class Download extends Response {
/** /**
......
<?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);
}
}
\ No newline at end of file
<?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 { ...@@ -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,16 +116,8 @@ class Inflector { ...@@ -116,16 +116,8 @@ 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
*/ */
public static function plural_if($value, $count) public static function plural_if($value, $count)
...@@ -136,14 +128,6 @@ class Inflector { ...@@ -136,14 +128,6 @@ class Inflector {
/** /**
* 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 @@ class Inflector { ...@@ -157,14 +141,6 @@ class Inflector {
/** /**
* 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
*/ */
......
<?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.
......
<?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 @@ date_default_timezone_set($application->config->get('application.timezone')); ...@@ -47,7 +47,9 @@ date_default_timezone_set($application->config->get('application.timezone'));
// -------------------------------------------------------------- // --------------------------------------------------------------
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 @@ class Loader { ...@@ -40,8 +40,6 @@ class Loader {
{ {
$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);
......
<?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.
......
<?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.
......
<?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.
......
<?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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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;
......
<?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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment