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

Reflection-based factory for controllers. More...

Public Member Functions

 __invoke (ContainerInterface $container, $requestedName, 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

 
 canCreate (ContainerInterface $container, $requestedName)
 Can the factory create an instance for the service?
Parameters
ContainerInterface$container
string$requestedName
Returns
bool

 

Protected Attributes

 $aliases
 

Detailed Description

Reflection-based factory for controllers.

To ease development, this factory may be used for controllers with type-hinted arguments that resolve to services in the application container; this allows omitting the step of writing a factory for each controller.

You may use it as either an abstract factory:

'controllers' => [ 'abstract_factories' => [ LazyControllerAbstractFactory::class, ], ],

Or as a factory, mapping a controller class name to it:

'controllers' => [ 'factories' => [ MyControllerWithDependencies::class => LazyControllerAbstractFactory::class, ], ],

The latter approach is more explicit, and also more performant.

The factory has the following constraints/features:

`$options` passed to the factory are ignored in all cases, as we cannot make assumptions about which argument(s) they might replace.

Member Function Documentation

__invoke ( ContainerInterface  $container,
  $requestedName,
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

Returns
DispatchableInterface

Implements FactoryInterface.

canCreate ( ContainerInterface  $container,
  $requestedName 
)

Can the factory create an instance for the service?

Parameters
ContainerInterface$container
string$requestedName
Returns
bool

Implements AbstractFactoryInterface.

Member Data Documentation

$aliases
protected
Initial value:
= [
ConsoleAdapterInterface::class => 'ConsoleAdapter'