Zend Framework  3.0
Public Member Functions | Public Attributes | Protected Attributes | List of all members
DiServiceFactory Class Reference

Factory for pulling a service from a DI container. More...

Public Member Functions

 __construct (Di $di, $useContainer=self::USE_SL_NONE)
 
 __invoke (ContainerInterface $container, $name, array $options=null)
 Create an object.
Parameters
ContainerInterface$container
string$requestedName
null | array$options
Returns
object
Exceptions
ServiceNotFoundExceptionif unable to resolve the service.
ServiceNotCreatedExceptionif an exception is raised when creating a service.
ContainerExceptionif any other error occurs

 
 createService (ServiceLocatorInterface $container, $name=null, $requestedName=null)
 zend-servicemanager v2 compatibility.
 
 setCreationOptions (array $options)
 zend-servicemanager v2 support for options passed to factory.
 
 get ($name, array $params=[])
 Override, as we want it to use the functionality defined in the proxy.
 
- Public Member Functions inherited from Di
 __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 Member Functions inherited from FactoryInterface
 createService (ServiceLocatorInterface $serviceLocator)
 Create service.
 

Public Attributes

const USE_SL_BEFORE_DI = 'before'
 #+ constants
 
const USE_SL_AFTER_DI = 'after'
 
const USE_SL_NONE = 'none'
 
- Public Attributes inherited from Di
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 Attributes

 $container = null
 
 $creationOptions = []
 
 $di = null
 
 $useContainer = self::USE_SL_AFTER_DI
 
- Protected Attributes inherited from Di
 $definitions = null
 
 $instanceManager = null
 
 $instanceContext = []
 
 $currentDependencies = []
 
 $currentAliasDependenencies = []
 
 $references = []
 

Additional Inherited Members

- Protected Member Functions inherited from Di
 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 inherited from Di
static isSubclassOf ($className, $type)
 Checks if the object has this class as one of its parents.
 

Detailed Description

Factory for pulling a service from a DI container.

This factory can be mapped to arbitrary class names, and used to pull them from the composed Di instance, using the following behaviors:

The DiAbstractServiceFactory extends this class in order to return and/or configure instances.

Constructor & Destructor Documentation

__construct ( Di  $di,
  $useContainer = self::USE_SL_NONE 
)
Parameters
Di$di
string$useContainer

Member Function Documentation

__invoke ( ContainerInterface  $container,
  $name,
array  $options = null 
)

Create an object.

Parameters
ContainerInterface$container
string$requestedName
null | array$options
Returns
object
Exceptions
ServiceNotFoundExceptionif unable to resolve the service.
ServiceNotCreatedExceptionif an exception is raised when creating a service.
ContainerExceptionif any other error occurs

Implements FactoryInterface.

createService ( ServiceLocatorInterface  $container,
  $name = null,
  $requestedName = null 
)

zend-servicemanager v2 compatibility.

Parameters
ServiceLocatorInterface$container
null | string$name
null | string$requestedName
Returns
object
get (   $name,
array  $params = [] 
)

Override, as we want it to use the functionality defined in the proxy.

Parameters
string$name
array$params
Returns
object
Exceptions
Exception\ServiceNotFoundException
setCreationOptions ( array  $options)

zend-servicemanager v2 support for options passed to factory.

Parameters
array$options
Returns
void

Member Data Documentation

$container = null
protected
$creationOptions = []
protected
$di = null
protected
$useContainer = self::USE_SL_AFTER_DI
protected
const USE_SL_AFTER_DI = 'after'
const USE_SL_BEFORE_DI = 'before'

#+ constants

const USE_SL_NONE = 'none'