Class Swift_DependencyContainer
Inheritance | Swift_DependencyContainer |
---|
Dependency Injection container.
Public Methods
Method | Description | Defined By |
---|---|---|
__construct() | Constructor should not be used. | Swift_DependencyContainer |
addConstructorLookup() | Specify a dependency lookup for the constructor of the previously registered item. | Swift_DependencyContainer |
addConstructorValue() | Specify a literal (non looked up) value for the constructor of the previously registered item. | Swift_DependencyContainer |
asAliasOf() | Specify the previously registered item as an alias of another item. | Swift_DependencyContainer |
asNewInstanceOf() | Specify the previously registered item as a new instance of $className. | Swift_DependencyContainer |
asSharedInstanceOf() | Specify the previously registered item as a shared instance of $className. | Swift_DependencyContainer |
asValue() | Specify the previously registered item as a literal value. | Swift_DependencyContainer |
createDependenciesFor() | Create an array of arguments passed to the constructor of $itemName. | Swift_DependencyContainer |
getInstance() | Returns a singleton of the DependencyContainer. | Swift_DependencyContainer |
has() | Test if an item is registered in this container with the given name. | Swift_DependencyContainer |
listItems() | List the names of all items stored in the Container. | Swift_DependencyContainer |
lookup() | Lookup the item with the given $itemName. | Swift_DependencyContainer |
register() | Register a new dependency with $itemName. | Swift_DependencyContainer |
withDependencies() | Specify a list of injected dependencies for the previously registered item. | Swift_DependencyContainer |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
TYPE_ALIAS | 4096 | Constant for aliases | Swift_DependencyContainer |
TYPE_INSTANCE | 16 | Constant for new instance types | Swift_DependencyContainer |
TYPE_SHARED | 256 | Constant for shared instance types | Swift_DependencyContainer |
TYPE_VALUE | 1 | Constant for literal value types | Swift_DependencyContainer |
Method Details
Constructor should not be used.
Use {@link getInstance()} instead.
public void __construct ( ) |
Specify a dependency lookup for the constructor of the previously registered item.
See also [[withDependencies(),]] addConstructorValue().
public Swift_DependencyContainer addConstructorLookup ( $lookup ) | ||
$lookup | string |
Specify a literal (non looked up) value for the constructor of the previously registered item.
See also [[withDependencies(),]] addConstructorLookup().
public Swift_DependencyContainer addConstructorValue ( $value ) | ||
$value | mixed |
Specify the previously registered item as an alias of another item.
public Swift_DependencyContainer asAliasOf ( $lookup ) | ||
$lookup | string |
Specify the previously registered item as a new instance of $className.
{@link register()} must be called before this will work. Any arguments can be set with {@link withDependencies()}, {@link addConstructorValue()} or {@link addConstructorLookup()}.
See also [[withDependencies(),]] addConstructorValue(), addConstructorLookup().
public Swift_DependencyContainer asNewInstanceOf ( $className ) | ||
$className | string |
Specify the previously registered item as a shared instance of $className.
{@link register()} must be called before this will work.
public Swift_DependencyContainer asSharedInstanceOf ( $className ) | ||
$className | string |
Specify the previously registered item as a literal value.
{@link register()} must be called before this will work.
public Swift_DependencyContainer asValue ( $value ) | ||
$value | mixed |
Create an array of arguments passed to the constructor of $itemName.
public array createDependenciesFor ( $itemName ) | ||
$itemName | string |
Returns a singleton of the DependencyContainer.
public static Swift_DependencyContainer getInstance ( ) |
Test if an item is registered in this container with the given name.
See also register().
public bool has ( $itemName ) | ||
$itemName | string |
List the names of all items stored in the Container.
public array listItems ( ) |
Lookup the item with the given $itemName.
See also register().
public mixed lookup ( $itemName ) | ||
$itemName | string | |
throws | Swift_DependencyException | If the dependency is not found |
---|
Register a new dependency with $itemName.
This method returns the current DependencyContainer instance because it requires the use of the fluid interface to set the specific details for the dependency.
See also [[asNewInstanceOf(),]] asSharedInstanceOf(), asValue().
public Swift_DependencyContainer register ( $itemName ) | ||
$itemName | string |
Specify a list of injected dependencies for the previously registered item.
This method takes an array of lookup names.
See also [[addConstructorValue(),]] addConstructorLookup().
public Swift_DependencyContainer withDependencies ( array $lookups ) | ||
$lookups | array |