velsym/dependency-injection
Dependency management system for PHP.
Velsym\DependencyInjection
DependencyManager
The heart of all instances.
Methods
loadDependencies(dependencies)
- setup method to use dependencies.Returns:
void
Params:
dependencies
- an array of dependencies (see DependencyBuilder on how to build own dependencies).
resolveClassToInstance(class, manualArguments[])
- returns fully instantiated object based on the givenclass
.Returns:
NULL|object
Params:
class
- class that will be resolved to an instance based on the dependency list given inloadDependencies
method. If class is not listed in the dependency list, it will try to construct class without using the dependency list.manualArguments[]
- (optional) key-value array of constructor arguments for the given class (note that dependencies can have default values for constructor parameters, therefore you can overwrite them).
callMethodWithResolvedArguments(object, methodName, manualArguments[])
- indirectly callsmethodName
onobject
withmanualArguments[]
and returns what themethodName
returns.Returns:
mixed
Params:
object
- object from which themethodName
will be called.methodName
- name of the method that is meant to be called.manualArguments[]
- (optional) key-value array of arguments for the method. Key is name of the method parameter.
getDependencies()
- returns an array of loaded dependencies.Returns:
array
Examples
Learn about DependencyBuilder to fully understand what's going on in How to use example.
Last updated