refactoring.
This commit is contained in:
@@ -12,17 +12,6 @@ class IoC {
|
||||
/**
|
||||
* Get the active container instance.
|
||||
*
|
||||
* The container is set early in the request cycle and can be access here for
|
||||
* use as a service locator if object injection is not practical.
|
||||
*
|
||||
* <code>
|
||||
* // Get the active container instance
|
||||
* $container = IoC::container();
|
||||
*
|
||||
* // Get the active container instance and call the resolve method
|
||||
* $container = IoC::container()->resolve('instance');
|
||||
* </code>
|
||||
*
|
||||
* @return Container
|
||||
*/
|
||||
public static function container()
|
||||
@@ -32,14 +21,6 @@ class IoC {
|
||||
|
||||
/**
|
||||
* Magic Method for calling methods on the active container instance.
|
||||
*
|
||||
* <code>
|
||||
* // Call the "resolve" method on the active container instance
|
||||
* $instance = IoC::resolve('instance');
|
||||
*
|
||||
* // Equivalent operation using the "container" method
|
||||
* $instance = IoC::container()->resolve('instance');
|
||||
* </code>
|
||||
*/
|
||||
public static function __callStatic($method, $parameters)
|
||||
{
|
||||
@@ -78,16 +59,6 @@ class Container {
|
||||
/**
|
||||
* Register an object and its resolver.
|
||||
*
|
||||
* The resolver function is called when the registered object is requested.
|
||||
*
|
||||
* <code>
|
||||
* // Register an object in the container
|
||||
* IoC::register('something', function($container) {return new Something;});
|
||||
*
|
||||
* // Register an object in the container as a singleton
|
||||
* IoC::register('something', function($container) {return new Something;}, true);
|
||||
* </code>
|
||||
*
|
||||
* @param string $name
|
||||
* @param Closure $resolver
|
||||
* @return void
|
||||
@@ -111,13 +82,8 @@ class Container {
|
||||
/**
|
||||
* Register an object as a singleton.
|
||||
*
|
||||
* 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 an object in the container as a singleton
|
||||
* IoC::singleton('something', function($container) {return new Something;});
|
||||
* </code>
|
||||
* Singletons will only be instantiated the first time they are resolved.
|
||||
* On subsequent requests for the object, the original instance will be returned.
|
||||
*
|
||||
* @param string $name
|
||||
* @param Closure $resolver
|
||||
@@ -131,13 +97,8 @@ class Container {
|
||||
/**
|
||||
* Register an instance as a singleton.
|
||||
*
|
||||
* This method allows you to register an already existing object instance with the
|
||||
* container to be managed as a singleton instance.
|
||||
*
|
||||
* <code>
|
||||
* // Register an instance with the IoC container
|
||||
* IoC::instance('something', new Something);
|
||||
* </code>
|
||||
* This method allows you to register an already existing object instance
|
||||
* with the container to be managed as a singleton instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $instance
|
||||
@@ -151,15 +112,6 @@ class Container {
|
||||
/**
|
||||
* Resolve an object.
|
||||
*
|
||||
* The object's resolver will be called and its result will be returned. If the
|
||||
* object is registered as a singleton and has already been resolved, the instance
|
||||
* that has already been instantiated will be returned.
|
||||
*
|
||||
* <code>
|
||||
* // Get the "something" object out of the IoC container
|
||||
* $something = IoC::resolve('something');
|
||||
* </code>
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -179,14 +131,6 @@ class Container {
|
||||
|
||||
/**
|
||||
* Magic Method for resolving classes out of the IoC container.
|
||||
*
|
||||
* <code>
|
||||
* // Get the "something" instance out of the IoC container
|
||||
* $something = IoC::container()->something;
|
||||
*
|
||||
* // Equivalent method of retrieving the instance using the resolve method
|
||||
* $something = IoC::container()->resolve('something');
|
||||
* </code>
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user