\Swift_DependencyContainer
Dependency Injection container.
- Author: Chris Corbyn
Synopsis
class Swift_DependencyContainer
{
- // constants
- const TYPE_VALUE = 0x0001;
- const TYPE_INSTANCE = 0x0010;
- const TYPE_SHARED = 0x0100;
- const TYPE_ALIAS = 0x1000;
- // members
- private $_instance;
- private array $_store;
- private $_endPoint;
- // methods
- public void __construct()
- public static Swift_DependencyContainer getInstance()
- public array listItems()
- public boolean has()
- public mixed lookup()
- public array createDependenciesFor()
- public Swift_DependencyContainer register()
- public Swift_DependencyContainer asValue()
- public Swift_DependencyContainer asAliasOf()
- public Swift_DependencyContainer asNewInstanceOf()
- public Swift_DependencyContainer asSharedInstanceOf()
- public Swift_DependencyContainer withDependencies()
- public Swift_DependencyContainer addConstructorValue()
- public Swift_DependencyContainer addConstructorLookup()
- private void _getValue()
- private void _createAlias()
- private void _createNewInstance()
- private void _createSharedInstance()
- private void _getEndPoint()
- private void _resolveArgs()
- private void _lookupRecursive()
Constants
Name | Value |
---|---|
TYPE_VALUE | 0x0001 |
TYPE_INSTANCE | 0x0010 |
TYPE_SHARED | 0x0100 |
TYPE_ALIAS | 0x1000 |
Members
private
-
$_endPoint
The current endpoint in the data container -
$_instance
Singleton instance -
$_store
The data container
Methods
private
- _createAlias() — Resolve an alias to another item
- _createNewInstance() — Create a fresh instance of $itemName
- _getEndPoint() — Get the current endpoint in the store
- _getValue() — Get the literal value with $itemName
- _lookupRecursive() — Resolve a single dependency with an collections
- _resolveArgs() — Get an argument list with dependencies resolved
public
- __construct() — Constructor should not be used.
- addConstructorLookup() — Specify a dependency lookup for the constructor of the previously registered item.
- addConstructorValue() — Specify a literal (non looked up) value for the constructor of the previously registered item.
- asAliasOf() — Specify the previously registered item as an alias of another item.
- asNewInstanceOf() — Specify the previously registered item as a new instance of $className.
- asValue() — Specify the previously registered item as a literal value.
- createDependenciesFor() — Create an array of arguments passed to the constructor of $itemName.
- getInstance() — Returns a singleton of the DependencyContainer.
- has() — Test if an item is registered in this container with the given name.
- listItems() — List the names of all items stored in the Container.
- lookup() — Lookup the item with the given $itemName.
- register() — Register a new dependency with $itemName.
- withDependencies() — Specify a list of injected dependencies for the previously registered item.