PHP Class Swift_DependencyContainer, Halite

Author: Chris Corbyn
Mostrar archivo Open project: HaliteChallenge/Halite Class Usage Examples

Public Methods

Method Description
__construct ( ) Constructor should not be used.
addConstructorLookup ( string $lookup ) : Swift_DependencyContainer Specify a dependency lookup for the constructor of the previously registered item.
addConstructorValue ( mixed $value ) : Swift_DependencyContainer Specify a literal (non looked up) value for the constructor of the previously registered item.
asAliasOf ( string $lookup ) : Swift_DependencyContainer Specify the previously registered item as an alias of another item.
asNewInstanceOf ( string $className ) : Swift_DependencyContainer Specify the previously registered item as a new instance of $className.
asSharedInstanceOf ( string $className ) : Swift_DependencyContainer Specify the previously registered item as a shared instance of $className.
asValue ( mixed $value ) : Swift_DependencyContainer Specify the previously registered item as a literal value.
createDependenciesFor ( string $itemName ) : array Create an array of arguments passed to the constructor of $itemName.
getInstance ( ) : Swift_DependencyContainer Returns a singleton of the DependencyContainer.
has ( string $itemName ) : boolean Test if an item is registered in this container with the given name.
listItems ( ) : array List the names of all items stored in the Container.
lookup ( string $itemName ) : mixed Lookup the item with the given $itemName.
register ( string $itemName ) : Swift_DependencyContainer Register a new dependency with $itemName.
withDependencies ( array $lookups ) : Swift_DependencyContainer Specify a list of injected dependencies for the previously registered item.

Private Methods

Method Description
_createAlias ( $itemName ) Resolve an alias to another item
_createNewInstance ( $itemName ) Create a fresh instance of $itemName
_createSharedInstance ( $itemName ) Create and register a shared instance of $itemName
_getEndPoint ( ) Get the current endpoint in the store
_getValue ( $itemName ) Get the literal value with $itemName
_lookupRecursive ( $item ) Resolve a single dependency with an collections
_resolveArgs ( array $args ) Get an argument list with dependencies resolved

Method Details

__construct() public method

Use {@link getInstance()} instead.
public __construct ( )

addConstructorLookup() public method

Specify a dependency lookup for the constructor of the previously registered item.
public addConstructorLookup ( string $lookup ) : Swift_DependencyContainer
$lookup string
return Swift_DependencyContainer

addConstructorValue() public method

Specify a literal (non looked up) value for the constructor of the previously registered item.
public addConstructorValue ( mixed $value ) : Swift_DependencyContainer
$value mixed
return Swift_DependencyContainer

asAliasOf() public method

Specify the previously registered item as an alias of another item.
public asAliasOf ( string $lookup ) : Swift_DependencyContainer
$lookup string
return Swift_DependencyContainer

asNewInstanceOf() public method

{@link register()} must be called before this will work. Any arguments can be set with {@link withDependencies()}, {@link addConstructorValue()} or {@link addConstructorLookup()}.
public asNewInstanceOf ( string $className ) : Swift_DependencyContainer
$className string
return Swift_DependencyContainer

asSharedInstanceOf() public method

{@link register()} must be called before this will work.
public asSharedInstanceOf ( string $className ) : Swift_DependencyContainer
$className string
return Swift_DependencyContainer

asValue() public method

{@link register()} must be called before this will work.
public asValue ( mixed $value ) : Swift_DependencyContainer
$value mixed
return Swift_DependencyContainer

createDependenciesFor() public method

Create an array of arguments passed to the constructor of $itemName.
public createDependenciesFor ( string $itemName ) : array
$itemName string
return array

getInstance() public static method

Returns a singleton of the DependencyContainer.
public static getInstance ( ) : Swift_DependencyContainer
return Swift_DependencyContainer

has() public method

Test if an item is registered in this container with the given name.
See also: register()
public has ( string $itemName ) : boolean
$itemName string
return boolean

listItems() public method

List the names of all items stored in the Container.
public listItems ( ) : array
return array

lookup() public method

Lookup the item with the given $itemName.
See also: register()
public lookup ( string $itemName ) : mixed
$itemName string
return mixed

register() public method

This method returns the current DependencyContainer instance because it requires the use of the fluid interface to set the specific details for the dependency.
public register ( string $itemName ) : Swift_DependencyContainer
$itemName string
return Swift_DependencyContainer

withDependencies() public method

This method takes an array of lookup names.
public withDependencies ( array $lookups ) : Swift_DependencyContainer
$lookups array
return Swift_DependencyContainer