368. Class

368.1. Zend\Di\Di

Dependency injector that can generate instances using class definitions and configured instance parameters

368.1.1. Methods

368.1.1.1. __construct

__construct()

Constructor

Parameters:
  • null|DefinitionList
  • null|InstanceManager
  • null|Config

368.1.1.2. configure

configure()

Provide a configuration object to configure this instance

Parameters:Config
Return type:void

368.1.1.3. setDefinitionList

setDefinitionList()

@param DefinitionList $definitions

Return type:self

368.1.1.4. definitions

definitions()

@return DefinitionList

368.1.1.5. setInstanceManager

setInstanceManager()

Set the instance manager

Parameters:InstanceManager
Return type:Di

368.1.1.6. instanceManager

instanceManager()

@return InstanceManager

368.1.1.7. getCallParameters

getCallParameters()

@param $name

Parameters:
  • array
  • string
Return type:

array

368.1.1.8. get

get()

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).

Parameters:
  • string – Class name or service alias
  • null|array – Parameters to pass to the constructor
Return type:

object|null

368.1.1.9. newInstance

newInstance()

Retrieve a new instance of a class

Forces retrieval of a discrete instance of the given class, using the constructor parameters provided.

Parameters:
  • mixed – Class name or service alias
  • array – Parameters to pass to the constructor
  • bool
Return type:

object|null

Throws :

ExceptionClassNotFoundException

Throws :

ExceptionRuntimeException

368.1.1.10. injectDependencies

injectDependencies()

Inject dependencies

Parameters:
  • object
  • array
Return type:

void

368.1.1.11. handleInjectDependencies

handleInjectDependencies()

@param object $instance

Parameters:
  • array
  • array
  • string|null
  • string|null$instanceAlias
  • string
Throws ExceptionRuntimeException:
 

368.1.1.12. createInstanceViaConstructor

createInstanceViaConstructor()

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.

Parameters:
  • string
  • array
  • string|null
Return type:

object

368.1.1.13. createInstanceViaCallback

createInstanceViaCallback()

Get an object instance from the defined callback

Parameters:
  • callable
  • array
  • string
Return type:

object

Throws :

ExceptionInvalidCallbackException

Throws :

ExceptionRuntimeException

368.1.1.14. resolveAndCallInjectionMethodForInstance

resolveAndCallInjectionMethodForInstance()

This parameter will handle any injection methods and resolution of dependencies for such methods

Parameters:
  • object
  • string
  • array
  • string
  • bool
  • string|null
Return type:

bool

368.1.1.15. resolveMethodParameters

resolveMethodParameters()

Resolve parameters referencing other services

Parameters:
  • string
  • string
  • array
  • string
  • bool
  • bool
Throws ExceptionMissingPropertyException:
 
Throws ExceptionCircularDependencyException:
 
Return type:

array

368.1.1.16. getClass

getClass()

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

Parameters:Object
Return type:string

368.1.1.17. isSubclassOf

isSubclassOf()

Checks if the object has this class as one of its parents

Parameters:
  • string
  • $type
Return type:

bool