XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
Swift_DependencyContainer Class Reference

Public Member Functions

 __construct ()
 
 addConstructorLookup ($lookup)
 
 addConstructorValue ($value)
 
 asAliasOf ($lookup)
 
 asNewInstanceOf ($className)
 
 asSharedInstanceOf ($className)
 
 asValue ($value)
 
 createDependenciesFor ($itemName)
 
 has ($itemName)
 
 listItems ()
 
 lookup ($itemName)
 
 register ($itemName)
 
 withDependencies (array $lookups)
 

Static Public Member Functions

static getInstance ()
 

Public Attributes

const TYPE_ALIAS = 0x1000
 
const TYPE_INSTANCE = 0x0010
 
const TYPE_SHARED = 0x0100
 
const TYPE_VALUE = 0x0001
 

Private Member Functions

 _createAlias ($itemName)
 
 _createNewInstance ($itemName)
 
 _createSharedInstance ($itemName)
 
_getEndPoint ()
 
 _getValue ($itemName)
 
 _lookupRecursive ($item)
 
 _resolveArgs (array $args)
 

Private Attributes

 $_endPoint
 
 $_store = array()
 

Static Private Attributes

static $_instance = null
 

Detailed Description

Definition at line 18 of file DependencyContainer.php.

Constructor & Destructor Documentation

Swift_DependencyContainer::__construct ( )

Constructor should not be used. Use getInstance() instead.

Definition at line 46 of file DependencyContainer.php.

Member Function Documentation

Swift_DependencyContainer::_createAlias (   $itemName)
private

Resolve an alias to another item

Definition at line 269 of file DependencyContainer.php.

References lookup().

Referenced by lookup().

Here is the call graph for this function:

Here is the caller graph for this function:

Swift_DependencyContainer::_createNewInstance (   $itemName)
private

Create a fresh instance of $itemName

Definition at line 275 of file DependencyContainer.php.

References createDependenciesFor().

Referenced by _createSharedInstance(), and lookup().

Here is the call graph for this function:

Here is the caller graph for this function:

Swift_DependencyContainer::_createSharedInstance (   $itemName)
private

Create and register a shared instance of $itemName

Definition at line 291 of file DependencyContainer.php.

References _createNewInstance().

Referenced by lookup().

Here is the call graph for this function:

Here is the caller graph for this function:

& Swift_DependencyContainer::_getEndPoint ( )
private

Get the current endpoint in the store

Definition at line 301 of file DependencyContainer.php.

References $_endPoint.

Referenced by addConstructorLookup(), addConstructorValue(), asAliasOf(), asNewInstanceOf(), asSharedInstanceOf(), asValue(), and withDependencies().

Here is the caller graph for this function:

Swift_DependencyContainer::_getValue (   $itemName)
private

Get the literal value with $itemName

Definition at line 263 of file DependencyContainer.php.

Referenced by lookup().

Here is the caller graph for this function:

Swift_DependencyContainer::_lookupRecursive (   $item)
private

Resolve a single dependency with an collections

Definition at line 332 of file DependencyContainer.php.

References lookup().

Referenced by _resolveArgs().

Here is the call graph for this function:

Here is the caller graph for this function:

Swift_DependencyContainer::_resolveArgs ( array  $args)
private

Get an argument list with dependencies resolved

Definition at line 313 of file DependencyContainer.php.

References _lookupRecursive().

Referenced by createDependenciesFor().

Here is the call graph for this function:

Here is the caller graph for this function:

Swift_DependencyContainer::addConstructorLookup (   $lookup)

Specify a dependency lookup for the constructor of the previously registered item.

Parameters
string$lookup
Returns
Swift_DependencyContainer
See Also
withDependencies(), addConstructorValue()

Definition at line 249 of file DependencyContainer.php.

References _getEndPoint().

Referenced by withDependencies().

Here is the call graph for this function:

Here is the caller graph for this function:

Swift_DependencyContainer::addConstructorValue (   $value)

Specify a literal (non looked up) value for the constructor of the previously registered item.

Parameters
mixed$value
Returns
Swift_DependencyContainer
See Also
withDependencies(), addConstructorLookup()

Definition at line 230 of file DependencyContainer.php.

References _getEndPoint().

Here is the call graph for this function:

Swift_DependencyContainer::asAliasOf (   $lookup)

Specify the previously registered item as an alias of another item.

Parameters
string$lookup
Returns
Swift_DependencyContainer

Definition at line 163 of file DependencyContainer.php.

References _getEndPoint().

Here is the call graph for this function:

Swift_DependencyContainer::asNewInstanceOf (   $className)

Specify the previously registered item as a new instance of $className. register() must be called before this will work. Any arguments can be set with withDependencies(), addConstructorValue() or addConstructorLookup().

Parameters
string$className
Returns
Swift_DependencyContainer
See Also
withDependencies(), addConstructorValue(), addConstructorLookup()

Definition at line 181 of file DependencyContainer.php.

References _getEndPoint().

Here is the call graph for this function:

Swift_DependencyContainer::asSharedInstanceOf (   $className)

Specify the previously registered item as a shared instance of $className. register() must be called before this will work.

Parameters
string$className
Returns
Swift_DependencyContainer

Definition at line 195 of file DependencyContainer.php.

References _getEndPoint().

Here is the call graph for this function:

Swift_DependencyContainer::asValue (   $value)

Specify the previously registered item as a literal value. register() must be called before this will work.

Parameters
mixed$value
Returns
Swift_DependencyContainer

Definition at line 150 of file DependencyContainer.php.

References _getEndPoint().

Here is the call graph for this function:

Swift_DependencyContainer::createDependenciesFor (   $itemName)

Create an array of arguments passed to the constructor of $itemName.

Parameters
string$itemName
Returns
array

Definition at line 116 of file DependencyContainer.php.

References _resolveArgs().

Referenced by _createNewInstance().

Here is the call graph for this function:

Here is the caller graph for this function:

Swift_DependencyContainer::has (   $itemName)

Test if an item is registered in this container with the given name.

Parameters
string$itemName
Returns
boolean
See Also
register()

Definition at line 76 of file DependencyContainer.php.

Referenced by lookup().

Here is the caller graph for this function:

Swift_DependencyContainer::listItems ( )

List the names of all items stored in the Container.

Returns
array

Definition at line 65 of file DependencyContainer.php.

Swift_DependencyContainer::lookup (   $itemName)

Lookup the item with the given $itemName.

Parameters
string$itemName
Returns
mixed
Exceptions
Swift_DependencyExceptionIf the dependency is not found
See Also
register()

Definition at line 89 of file DependencyContainer.php.

References _createAlias(), _createNewInstance(), _createSharedInstance(), _getValue(), and has().

Referenced by _createAlias(), and _lookupRecursive().

Here is the call graph for this function:

Here is the caller graph for this function:

Swift_DependencyContainer::register (   $itemName)

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.

Parameters
string$itemName
Returns
Swift_DependencyContainer
See Also
asNewInstanceOf(), asSharedInstanceOf(), asValue()

Definition at line 136 of file DependencyContainer.php.

Swift_DependencyContainer::withDependencies ( array  $lookups)

Specify a list of injected dependencies for the previously registered item. This method takes an array of lookup names.

Parameters
array$lookups
Returns
Swift_DependencyContainer
See Also
addConstructorValue(), addConstructorLookup()

Definition at line 211 of file DependencyContainer.php.

References _getEndPoint(), and addConstructorLookup().

Here is the call graph for this function:

Member Data Documentation

Swift_DependencyContainer::$_endPoint
private

The current endpoint in the data container

Definition at line 40 of file DependencyContainer.php.

Referenced by _getEndPoint().

Swift_DependencyContainer::$_instance = null
staticprivate

Singleton instance

Definition at line 34 of file DependencyContainer.php.

Swift_DependencyContainer::$_store = array()
private

The data container

Definition at line 37 of file DependencyContainer.php.

const Swift_DependencyContainer::TYPE_ALIAS = 0x1000

Constant for aliases

Definition at line 31 of file DependencyContainer.php.

const Swift_DependencyContainer::TYPE_INSTANCE = 0x0010

Constant for new instance types

Definition at line 25 of file DependencyContainer.php.

const Swift_DependencyContainer::TYPE_SHARED = 0x0100

Constant for shared instance types

Definition at line 28 of file DependencyContainer.php.

const Swift_DependencyContainer::TYPE_VALUE = 0x0001

Constant for literal value types

Definition at line 22 of file DependencyContainer.php.


The documentation for this class was generated from the following file: