Commit f113b5c8 authored by Taylor Otwell's avatar Taylor Otwell

refactoring for dependency injection.

parent 8229891d
......@@ -9,11 +9,6 @@ class Arr {
* also be accessed using JavaScript "dot" style notation. Retrieving items nested
* in multiple arrays is also supported.
*
* <code>
* // Returns "taylor"
* Arr::get(array('name' => array('is' => 'Taylor')), 'name.is');
* </code>
*
* @param array $array
* @param string $key
* @param mixed $default
......@@ -47,11 +42,6 @@ class Arr {
*
* Like the Arr::get method, JavaScript "dot" syntax is supported.
*
* <code>
* // Set "name.is" to "taylor"
* Arr::set(array('name' => array('is' => 'something')), 'name.is', 'taylor');
* </code>
*
* @param array $array
* @param string $key
* @param mixed $value
......
......@@ -14,14 +14,6 @@ class Config {
/**
* Determine if a configuration item or file exists.
*
* <code>
* // Determine if the "session" configuration file exists
* Config::has('session');
*
* // Determine if the application timezone option exists
* Config::has('application.timezone');
* </code>
*
* @param string $key
* @return bool
*/
......@@ -40,14 +32,6 @@ class Config {
* If the name of a configuration file is passed without specifying an item, the
* entire configuration array will be returned.
*
* <code>
* // Get the timezone option from the application configuration file
* $timezone = Config::get('application.timezone');
*
* // Get the SQLite database connection configuration
* $sqlite = Config::get('database.connections.sqlite');
* </code>
*
* @param string $key
* @param string $default
* @return array
......@@ -75,14 +59,6 @@ class Config {
* If a specific configuration item is not specified, the entire configuration
* array will be replaced with the given value.
*
* <code>
* // Set the timezone option in the application configuration file
* Config::set('application.timezone', 'America/Chicago');
*
* // Set the session configuration array
* Config::set('session', array());
* </code>
*
* @param string $key
* @param mixed $value
* @return void
......
......@@ -4,7 +4,7 @@ return array(
/*
|--------------------------------------------------------------------------
| Laravel Support Components
| Laravel Components
|--------------------------------------------------------------------------
*/
......@@ -59,7 +59,7 @@ return array(
'laravel.redirect' => array('singleton' => true, 'resolver' => function($container)
{
return new Redirect($container->resolve('laravel.url'));
return new Redirect($container->resolve('laravel.session.driver'), $container->resolve('laravel.url'));
}),
......
......@@ -21,11 +21,6 @@ class IoC {
/**
* Magic Method for calling methods on the active container instance.
*
* <code>
* // Get the request registered in the container
* $request = IoC::resolve('laravel.request');
* </code>
*/
public static function __callStatic($method, $parameters)
{
......@@ -69,14 +64,6 @@ class Container {
*
* The resolver function when the registered dependency is requested.
*
* <code>
* // Register a simple dependency
* $container->register('name', function() { return 'Fred'; });
*
* // Register a dependency as a singleton
* $container->register('name', function() { return new Name; }, true);
* </code>
*
* @param string $name
* @param Closure $resolver
* @return void
......@@ -89,11 +76,6 @@ class Container {
/**
* Determine if a dependency has been registered in the container.
*
* <code>
* // Determine if the "user" dependency is registered in the container
* $registered = $container->registered('user');
* </code>
*
* @param string $name
* @return bool
*/
......@@ -108,11 +90,6 @@ class Container {
* Singletons will only be instantiated the first time they are resolved. On subsequent
* requests for the object, the original instance will be returned.
*
* <code>
* // Register a dependency as a singleton
* $container->singleton('user', function() { return new User; })
* </code>
*
* @param string $name
* @param Closure $resolver
* @return void
......@@ -128,11 +105,6 @@ class Container {
* This method allows you to register an already existing object instance with the
* container as a singleton instance.
*
* <code>
* // Register an object instance as a singleton in the container
* $container->instance('user', new User);
* </code>
*
* @param string $name
* @param mixed $instance
* @return void
......@@ -147,11 +119,6 @@ class Container {
*
* The dependency's resolver will be called and its result will be returned.
*
* <code>
* // Resolver the "name" dependency
* $name = $container->resolve('name');
* </code>
*
* @param string $name
* @return mixed
*/
......
......@@ -17,9 +17,7 @@ abstract class Controller {
*/
public function __get($key)
{
$application = IoC::resolve('laravel.application');
return $application->$key;
return IoC::resolve('laravel.application')->$key;
}
/**
......
......@@ -124,13 +124,6 @@ class File {
/**
* Get a file MIME type by extension.
*
* Any extension in the MIMEs configuration file may be passed to the method.
*
* <code>
* // Returns "application/x-tar"
* $mime = $file->mime('tar');
* </code>
*
* @param string $extension
* @param string $default
* @return string
......@@ -145,13 +138,7 @@ class File {
/**
* Determine if a file is a given type.
*
* The Fileinfo PHP extension will be used to determine the MIME type of the file. Any extension
* in the MIMEs configuration file may be passed as a type.
*
* <code>
* // Determine if the file is a JPG image
* $image = $file->is('jpg', 'path/to/image.jpg');
* </code>
* The Fileinfo PHP extension will be used to determine the MIME type of the file.
*
* @param string $extension
* @param string $path
......
......@@ -80,14 +80,6 @@ class Input {
*
* This method should be used for all request methods (GET, POST, PUT, and DELETE).
*
* <code>
* // Get the "name" item from the input data
* $name = Request::active()->input->get('name');
*
* // Get the "name" item and return "Fred" if it doesn't exist.
* $name = Request::active()->input->get('name', 'Fred');
* </code>
*
* @param string $key
* @param mixed $default
* @return string
......@@ -111,11 +103,6 @@ class Input {
/**
* Get input data from the previous request.
*
* <code>
* // Get the "name" item from the old input data
* $name = Request::active()->input->old('name');
* </code>
*
* @param string $key
* @param mixed $default
* @return string
......@@ -132,14 +119,6 @@ class Input {
*
* "Dot" syntax may be used to get a specific item from the file array.
*
* <code>
* // Get the array of information regarding a given file
* $file = Request::active()->input->file('picture');
*
* // Get the size of a given file
* $file = Request::active()->input->file('picture.size');
* </code>
*
* @param string $key
* @param mixed $default
* @return array
......@@ -165,11 +144,6 @@ class Input {
/**
* Magic Method for retrieving items from the request input.
*
* <code>
* // Retrieve the "name" item from the input data
* $name = Request::active()->input->name;
* </code>
*/
public function __get($key)
{
......
......@@ -52,14 +52,6 @@ class Lang {
* 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.
*
* <code>
* // Get the "required" line from the "validation" language file
* $line = Lang::line('validation.required')->get();
*
* // Specify a replacement for a language line
* $line = Lang::line('welcome.message', array('name' => 'Fred'))->get();
* </code>
*
* @param string $key
* @param array $replacements
* @return Lang
......@@ -74,11 +66,6 @@ class Lang {
*
* A default value may also be specified, which will be returned in the language line doesn't exist.
*
* <code>
* // Get a validation line and return a default value if the line doesn't exist
* $line = Lang::line('welcome.message')->get('Hello!');
* </code>
*
* @param string $language
* @return string
*/
......@@ -156,11 +143,6 @@ class Lang {
*
* The language specified in this method should correspond to a language directory in your application.
*
* <code>
* // Get a "fr" language line
* $line = Lang::line('validation.required')->in('fr')->get();
* </code>
*
* @param string $language
* @return Lang
*/
......
......@@ -2,15 +2,31 @@
class Redirect extends Response {
/**
* The URL generator instance.
*
* @var URL
*/
private $url;
/**
* The active session driver instance.
*
* @var Session\Driver
*/
private $session;
/**
* Create a new redirect generator instance.
*
* @param URL $url
* @param Session\Driver $session
* @param URL $url
* @return void
*/
public function __construct(URL $url)
public function __construct(Session\Driver $session, URL $url)
{
$this->url = $url;
$this->session = $session;
}
/**
......@@ -62,7 +78,7 @@ class Redirect extends Response {
*/
public function with($key, $value)
{
IoC::container()->resolve('laravel.session.driver')->flash($key, $value);
$this->session->flash($key, $value);
return $this;
}
......
......@@ -223,14 +223,4 @@ class Response {
return $this;
}
/**
* Magic Method for passing undefined static methods to the Response_Factory instance
* registered in the application IoC container. This provides easy access to the
* response functions while still maintaining testability within the classes.
*/
public static function __callStatic($method, $parameters)
{
return call_user_func_array(array(IoC::container()->resolve('laravel.response'), $method), $parameters);
}
}
\ No newline at end of file
......@@ -296,14 +296,4 @@ class View {
unset($this->data[$key]);
}
/**
* Magic Method for passing undefined static methods to the View_Factory instance
* registered in the application IoC container. This provides easy access to the
* view functions while still maintaining testability within the view classes.
*/
public static function __callStatic($method, $parameters)
{
return call_user_func_array(array(IoC::container()->resolve('laravel.view'), $method), $parameters);
}
}
\ No newline at end of file
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