Swift_DependencyContainer
in package
Dependency Injection container.
Tags
Table of Contents
- TYPE_ALIAS = 0x1000
- Constant for aliases
- TYPE_ARRAY = 0x10000
- Constant for arrays
- TYPE_INSTANCE = 0x10
- Constant for new instance types
- TYPE_SHARED = 0x100
- Constant for shared instance types
- TYPE_VALUE = 0x1
- Constant for literal value types
- $endPoint : mixed
- The current endpoint in the data container
- $instance : mixed
- Singleton instance
- $store : mixed
- The data container
- __construct() : mixed
- Constructor should not be used.
- addConstructorLookup() : $this
- Specify a dependency lookup for the constructor of the previously registered item.
- addConstructorValue() : $this
- Specify a literal (non looked up) value for the constructor of the previously registered item.
- asAliasOf() : $this
- Specify the previously registered item as an alias of another item.
- asArray() : $this
- Specify the previously registered item as array of dependencies.
- asNewInstanceOf() : $this
- Specify the previously registered item as a new instance of $className.
- asSharedInstanceOf() : $this
- Specify the previously registered item as a shared instance of $className.
- asValue() : $this
- Specify the previously registered item as a literal value.
- createDependenciesFor() : array<string|int, mixed>
- Create an array of arguments passed to the constructor of $itemName.
- getInstance() : self
- Returns a singleton of the DependencyContainer.
- has() : bool
- Test if an item is registered in this container with the given name.
- listItems() : array<string|int, mixed>
- List the names of all items stored in the Container.
- lookup() : mixed
- Lookup the item with the given $itemName.
- register() : $this
- Register a new dependency with $itemName.
- withDependencies() : $this
- Specify a list of injected dependencies for the previously registered item.
- createAlias() : mixed
- Resolve an alias to another item
- createNewInstance() : mixed
- Create a fresh instance of $itemName
- createSharedInstance() : mixed
- Create and register a shared instance of $itemName
- getEndPoint() : mixed
- Get the current endpoint in the store
- getValue() : mixed
- Get the literal value with $itemName
- lookupRecursive() : mixed
- Resolve a single dependency with an collections
- resolveArgs() : mixed
- Get an argument list with dependencies resolved
Constants
TYPE_ALIAS
Constant for aliases
public
mixed
TYPE_ALIAS
= 0x1000
TYPE_ARRAY
Constant for arrays
public
mixed
TYPE_ARRAY
= 0x10000
TYPE_INSTANCE
Constant for new instance types
public
mixed
TYPE_INSTANCE
= 0x10
TYPE_SHARED
Constant for shared instance types
public
mixed
TYPE_SHARED
= 0x100
TYPE_VALUE
Constant for literal value types
public
mixed
TYPE_VALUE
= 0x1
Properties
$endPoint
The current endpoint in the data container
private
mixed
$endPoint
$instance
Singleton instance
private
static mixed
$instance
=
ull
$store
The data container
private
mixed
$store
= []
Methods
__construct()
Constructor should not be used.
public
__construct() : mixed
Return values
mixed —addConstructorLookup()
Specify a dependency lookup for the constructor of the previously registered item.
public
addConstructorLookup(string $lookup) : $this
Parameters
- $lookup : string
Tags
Return values
$this —addConstructorValue()
Specify a literal (non looked up) value for the constructor of the previously registered item.
public
addConstructorValue(mixed $value) : $this
Parameters
- $value : mixed
Tags
Return values
$this —asAliasOf()
Specify the previously registered item as an alias of another item.
public
asAliasOf(string $lookup) : $this
Parameters
- $lookup : string
Return values
$this —asArray()
Specify the previously registered item as array of dependencies.
public
asArray() : $this
Return values
$this —asNewInstanceOf()
Specify the previously registered item as a new instance of $className.
public
asNewInstanceOf(string $className) : $this
must be called before this will work. Any arguments can be set with , or .
Parameters
- $className : string
Tags
Return values
$this —asSharedInstanceOf()
Specify the previously registered item as a shared instance of $className.
public
asSharedInstanceOf(string $className) : $this
Parameters
- $className : string
Return values
$this —asValue()
Specify the previously registered item as a literal value.
public
asValue(mixed $value) : $this
Parameters
- $value : mixed
Return values
$this —createDependenciesFor()
Create an array of arguments passed to the constructor of $itemName.
public
createDependenciesFor(string $itemName) : array<string|int, mixed>
Parameters
- $itemName : string
Return values
array<string|int, mixed> —getInstance()
Returns a singleton of the DependencyContainer.
public
static getInstance() : self
Return values
self —has()
Test if an item is registered in this container with the given name.
public
has(string $itemName) : bool
Parameters
- $itemName : string
Tags
Return values
bool —listItems()
List the names of all items stored in the Container.
public
listItems() : array<string|int, mixed>
Return values
array<string|int, mixed> —lookup()
Lookup the item with the given $itemName.
public
lookup(string $itemName) : mixed
Parameters
- $itemName : string
Tags
Return values
mixed —register()
Register a new dependency with $itemName.
public
register(string $itemName) : $this
This method returns the current DependencyContainer instance because it requires the use of the fluid interface to set the specific details for the dependency.
Parameters
- $itemName : string
Tags
Return values
$this —withDependencies()
Specify a list of injected dependencies for the previously registered item.
public
withDependencies(array<string|int, mixed> $lookups) : $this
This method takes an array of lookup names.
Parameters
- $lookups : array<string|int, mixed>
Tags
Return values
$this —createAlias()
Resolve an alias to another item
private
createAlias(mixed $itemName) : mixed
Parameters
- $itemName : mixed
Return values
mixed —createNewInstance()
Create a fresh instance of $itemName
private
createNewInstance(mixed $itemName) : mixed
Parameters
- $itemName : mixed
Return values
mixed —createSharedInstance()
Create and register a shared instance of $itemName
private
createSharedInstance(mixed $itemName) : mixed
Parameters
- $itemName : mixed
Return values
mixed —getEndPoint()
Get the current endpoint in the store
private
getEndPoint() : mixed
Return values
mixed —getValue()
Get the literal value with $itemName
private
getValue(mixed $itemName) : mixed
Parameters
- $itemName : mixed
Return values
mixed —lookupRecursive()
Resolve a single dependency with an collections
private
lookupRecursive(mixed $item) : mixed
Parameters
- $item : mixed
Return values
mixed —resolveArgs()
Get an argument list with dependencies resolved
private
resolveArgs(array<string|int, mixed> $args) : mixed
Parameters
- $args : array<string|int, mixed>