Zend Framework
3.0
|
Dependency injector that can generate instances using class definitions and configured instance parameters. More...
Public Member Functions | |
__construct (DefinitionList $definitions=null, InstanceManager $instanceManager=null, Config $config=null) | |
Constructor. | |
configure (Config $config) | |
Provide a configuration object to configure this instance. | |
setDefinitionList (DefinitionList $definitions) | |
definitions () | |
setInstanceManager (InstanceManager $instanceManager) | |
Set the instance manager. | |
instanceManager () | |
has ($name) | |
Is the DI container capable of returning the named instance? | |
get ($name, array $params=[]) | |
Lazy-load a class. | |
newInstance ($name, array $params=[], $isShared=true) | |
Retrieve a new instance of a class. | |
injectDependencies ($instance, array $params=[]) | |
Inject dependencies. | |
Public Member Functions inherited from DependencyInjectionInterface | |
newInstance ($name, array $params=[]) | |
Retrieve a new instance of a class. | |
Public Attributes | |
const | RESOLVE_EAGER = 1 |
Resolve method policy. | |
const | RESOLVE_STRICT = 2 |
Resolve method policy. | |
const | METHOD_IS_OPTIONAL = 0 |
use only specified parameters | |
const | METHOD_IS_AWARE = 1 |
resolve mode RESOLVE_EAGER | |
const | METHOD_IS_CONSTRUCTOR = 3 |
resolve mode RESOLVE_EAGER | RESOLVE_STRICT | |
const | METHOD_IS_INSTANTIATOR = 3 |
resolve mode RESOLVE_EAGER | RESOLVE_STRICT | |
const | METHOD_IS_REQUIRED = 3 |
resolve mode RESOLVE_EAGER | RESOLVE_STRICT | |
const | METHOD_IS_EAGER = 1 |
resolve mode RESOLVE_EAGER | |
Protected Member Functions | |
getClass ($instance) | |
Utility method used to retrieve the class of a particular instance. | |
getCallParameters ($name, array $params, $method="__construct") | |
handleInjectDependencies ($instance, $injectionMethods, $params, $instanceClass, $instanceAlias, $requestedName) | |
createInstanceViaConstructor ($class, $params, $alias=null) | |
Retrieve a class instance based on class name. | |
createInstanceViaCallback ($callback, $params, $alias) | |
Get an object instance from the defined callback. | |
resolveAndCallInjectionMethodForInstance ($instance, $method, $params, $alias, $methodRequirementType, $methodClass=null) | |
This parameter will handle any injection methods and resolution of dependencies for such methods. | |
resolveMethodParameters ($class, $method, array $callTimeUserParams, $alias, $methodRequirementType, $isInstantiator=false) | |
Resolve parameters referencing other services. | |
Static Protected Member Functions | |
static | isSubclassOf ($className, $type) |
Checks if the object has this class as one of its parents. | |
Protected Attributes | |
$definitions = null | |
$instanceManager = null | |
$instanceContext = [] | |
$currentDependencies = [] | |
$currentAliasDependenencies = [] | |
$references = [] | |
Dependency injector that can generate instances using class definitions and configured instance parameters.
__construct | ( | DefinitionList | $definitions = null , |
InstanceManager | $instanceManager = null , |
||
Config | $config = null |
||
) |
Constructor.
null | DefinitionList | $definitions | |
null | InstanceManager | $instanceManager | |
null | Config | $config |
configure | ( | Config | $config | ) |
|
protected |
Get an object instance from the defined callback.
callable | $callback | |
array | $params | |
string | $alias |
Exception\InvalidCallbackException | |
Exception\RuntimeException |
|
protected |
Retrieve a class instance based on class name.
Any parameters provided will be used as constructor arguments. If any given parameter is a DependencyReference object, it will be fetched from the container so that the instance may be injected.
string | $class | |
array | $params | |
string | null | $alias |
definitions | ( | ) |
get | ( | $name, | |
array | $params = [] |
||
) |
Lazy-load a class.
Attempts to load the class (or service alias) provided. If it has been loaded before, the previous instance will be returned (unless the service definition indicates shared instances should not be used).
string | $name | Class name or service alias |
null | array | $params | Parameters to pass to the constructor |
|
protected |
$name | ||
array | $params | |
string | $method |
|
protected |
Utility method used to retrieve the class of a particular instance.
This is here to allow extending classes to override how class names are resolved
|
protected |
object | $instance | |
array | $injectionMethods | |
array | $params | |
string | null | $instanceClass | |
string|null$instanceAlias | ||
string | $requestedName |
Exception\RuntimeException |
has | ( | $name | ) |
Is the DI container capable of returning the named instance?
string | $name |
injectDependencies | ( | $instance, | |
array | $params = [] |
||
) |
Inject dependencies.
object | $instance | |
array | $params |
instanceManager | ( | ) |
|
staticprotected |
Checks if the object has this class as one of its parents.
string | $className | |
$type |
newInstance | ( | $name, | |
array | $params = [] , |
||
$isShared = true |
|||
) |
Retrieve a new instance of a class.
Forces retrieval of a discrete instance of the given class, using the constructor parameters provided.
mixed | $name | Class name or service alias |
array | $params | Parameters to pass to the constructor |
bool | $isShared |
Exception\ClassNotFoundException | |
Exception\RuntimeException |
|
protected |
This parameter will handle any injection methods and resolution of dependencies for such methods.
object | $instance | |
string | $method | |
array | $params | |
string | $alias | |
bool | $methodRequirementType | |
string | null | $methodClass |
|
protected |
Resolve parameters referencing other services.
string | $class | |
string | $method | |
array | $callTimeUserParams | |
string | $alias | |
int | bool | $methodRequirementType | |
bool | $isInstantiator |
Exception\MissingPropertyException | |
Exception\CircularDependencyException |
setDefinitionList | ( | DefinitionList | $definitions | ) |
DefinitionList | $definitions |
setInstanceManager | ( | InstanceManager | $instanceManager | ) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
const METHOD_IS_AWARE = 1 |
resolve mode RESOLVE_EAGER
const METHOD_IS_CONSTRUCTOR = 3 |
resolve mode RESOLVE_EAGER | RESOLVE_STRICT
const METHOD_IS_EAGER = 1 |
resolve mode RESOLVE_EAGER
const METHOD_IS_INSTANTIATOR = 3 |
resolve mode RESOLVE_EAGER | RESOLVE_STRICT
const METHOD_IS_OPTIONAL = 0 |
use only specified parameters
const METHOD_IS_REQUIRED = 3 |
resolve mode RESOLVE_EAGER | RESOLVE_STRICT
const RESOLVE_EAGER = 1 |
Resolve method policy.
EAGER: explore type preference or go through
const RESOLVE_STRICT = 2 |
Resolve method policy.
STRICT: explore type preference or throw exception