Class Container

Description

The Container class.

  • since: 1.0

Located in /libraries/framework/Joomla/DI/Container.php (line 18)


	
			
Variable Summary
Method Summary
 Container __construct ([Container $parent = null])
 Container alias (string $alias, string $key)
 mixed buildObject (string $key, [boolean $shared = false])
 object Instance buildSharedObject (string $key)
 void extend (string $key, Closure \$callable, \Closure $callable)
 mixed get (string $key, [boolean $forceNew = false])
 array getMethodArgs (ReflectionMethod \$method, \ReflectionMethod $method)
 mixed getNewInstance (string $key)
 mixed getRaw (string $key)
 \Joomla\DI\Container protect (string $key, callable $callback, [bool $shared = false])
 string resolveAlias (string $key)
 \Joomla\DI\Container set (string $key, mixed $value, [boolean $shared = false], [boolean $protected = false])
 \Joomla\DI\Container share (string $key, callable $callback, [bool $protected = false])
Variables
array $aliases = array() (line 27)

Holds the key aliases.

  • since: 1.0
  • access: protected
array $dataStore = array() (line 46)

Holds the keys, their callbacks, and whether or not the item is meant to be a shared resource.

  • since: 1.0
  • access: protected
array $instances = array() (line 36)

Holds the shared instances.

  • since: 1.0
  • access: protected
Container $parent (line 55)

Parent for hierarchical containers.

  • since: 1.0
  • access: protected
Methods
Constructor __construct (line 64)

Constructor for the DI Container

  • since: 1.0
  • access: public
Container __construct ([Container $parent = null])
  • Container $parent: Parent for hierarchical containers.
alias (line 77)

Create an alias for a given key for easy access.

  • access: public
Container alias (string $alias, string $key)
  • string $alias: The alias name
  • string $key: The key to alias
buildObject (line 114)

Build an object of class $key;

  • return: Instance of class specified by $key with all dependencies injected. Returns an object if the class exists and false otherwise
  • since: 1.0
  • access: public
mixed buildObject (string $key, [boolean $shared = false])
  • string $key: The class name to build.
  • boolean $shared: True to create a shared resource.
buildSharedObject (line 156)

Convenience method for building a shared object.

  • return: of class specified by $key with all dependencies injected.
  • since: 1.0
  • access: public
object Instance buildSharedObject (string $key)
  • string $key: The class name to build.
createChild (line 169)

Create a child Container with a new property scope that that has the ability to access the parent scope when resolving.

  • since: 1.0
  • access: public
Container createChild ()
extend (line 187)

Extend a defined service Closure by wrapping the existing one with a new Closure. This works very similar to a decorator pattern. Note that this only works on service Closures that have been defined in the current Provider, not parent providers.

  • since: 1.0
  • throws: \InvalidArgumentException
  • access: public
void extend (string $key, Closure \$callable, \Closure $callable)
  • string $key: The unique identifier for the Closure or property.
  • \Closure $callable: A Closure to wrap the original service Closure.
  • Closure \$callable
get (line 339)

Method to retrieve the results of running the $callback for the specified $key;

  • return: Results of running the $callback for the specified $key.
  • since: 1.0
  • throws: \InvalidArgumentException
  • access: public
mixed get (string $key, [boolean $forceNew = false])
  • string $key: Name of the dataStore key to get.
  • boolean $forceNew: True to force creation and return of a new instance.
getMethodArgs (line 213)

Build an array of constructor parameters.

  • return: Array of arguments to pass to the method.
  • since: 1.0
  • throws: DependencyResolutionException
  • access: protected
array getMethodArgs (ReflectionMethod \$method, \ReflectionMethod $method)
  • \ReflectionMethod $method: Method for which to build the argument array.
  • ReflectionMethod \$method
getNewInstance (line 394)

Method to force the container to return a new instance of the results of the callback for requested $key.

  • return: Results of running the $callback for the specified $key.
  • since: 1.0
  • access: public
mixed getNewInstance (string $key)
  • string $key: Name of the dataStore key to get.
getRaw (line 368)

Get the raw data assigned to a key.

  • access: protected
mixed getRaw (string $key)
  • string $key: The key for which to get the stored item.
protect (line 307)

Convenience method for creating protected keys.

  • return: This instance to support chaining.
  • since: 1.0
  • access: public
\Joomla\DI\Container protect (string $key, callable $callback, [bool $shared = false])
  • string $key: Name of dataStore key to set.
  • callable $callback: Callable function to run when requesting the specified $key.
  • bool $shared: True to create and store a shared instance.
registerServiceProvider (line 408)

Register a service provider to the container.

  • return: This object for chaining.
  • since: 1.0
  • access: public
Container registerServiceProvider (ServiceProviderInterface $provider)
resolveAlias (line 93)

Search the aliases property for a matching alias key.

  • since: 1.0
  • access: protected
string resolveAlias (string $key)
  • string $key: The key to search for.
set (line 272)

Method to set the key and callback to the dataStore array.

  • return: This instance to support chaining.
  • throws: \OutOfBoundsException Thrown if the provided key is already set and is protected.
  • since: 1.0
  • access: public
\Joomla\DI\Container set (string $key, mixed $value, [boolean $shared = false], [boolean $protected = false])
  • string $key: Name of dataStore key to set.
  • mixed $value: Callable function to run or string to retrive when requesting the specified $key.
  • boolean $shared: True to create and store a shared instance.
  • boolean $protected: True to protect this item from being overwritten. Useful for services.
share (line 323)

Convenience method for creating shared keys.

  • return: This instance to support chaining.
  • since: 1.0
  • access: public
\Joomla\DI\Container share (string $key, callable $callback, [bool $protected = false])
  • string $key: Name of dataStore key to set.
  • callable $callback: Callable function to run when requesting the specified $key.
  • bool $protected: True to create and store a shared instance.

Documentation generated on Tue, 19 Nov 2013 14:56:48 +0100 by phpDocumentor 1.4.3