Zend Framework  3.0
Public Member Functions | List of all members
WriterFactory Class Reference

Factory for instantiating classes with no dependencies or which accept a single array. More...

Public Member Functions

 __construct (array $creationOptions=null)
 
 __invoke (ContainerInterface $container, $requestedName, array $options=null)
 Create an instance of the requested class name.
 
 createService (ServiceLocatorInterface $serviceLocator, $canonicalName=null, $requestedName=null)
 Create an instance of the named service.
 
 setCreationOptions (array $creationOptions)
 {}
 
- Public Member Functions inherited from FactoryInterface
 createService (ServiceLocatorInterface $serviceLocator)
 Create service.
 

Detailed Description

Factory for instantiating classes with no dependencies or which accept a single array.

The WriterFactory can be used for any class that:

It replaces the "invokables" and "invokable class" functionality of the v2 service manager, and can also be used in v2 code for forwards compatibility with v3.

Constructor & Destructor Documentation

__construct ( array  $creationOptions = null)
Parameters
array$creationOptions

Member Function Documentation

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

Create an instance of the requested class name.

Parameters
ContainerInterface$container
string$requestedName
null | array$options
Returns
object

Implements FactoryInterface.

createService ( ServiceLocatorInterface  $serviceLocator,
  $canonicalName = null,
  $requestedName = null 
)

Create an instance of the named service.

First, it checks if `$canonicalName` resolves to a class, and, if so, uses that value to proxy to `__invoke()`.

Next, if `$requestedName` is non-empty and resolves to a class, this method uses that value to proxy to `__invoke()`.

Finally, if the above each fail, it raises an exception.

The approach above is performed as version 2 has two distinct behaviors under which factories are invoked:

  • If an alias was used, $canonicalName is the resolved name, and $requestedName is the service name requested, in which case $canonicalName is likely the qualified class name;
  • Otherwise, $canonicalName is the normalized name, and $requestedName is the original service name requested (typically the qualified class name).
Parameters
ServiceLocatorInterface$serviceLocator
null | string$canonicalName
null | string$requestedName
Returns
object
Exceptions
InvalidServiceException
setCreationOptions ( array  $creationOptions)

{}