Zend Framework
3.0
|
Reflection-based factory for controllers. More...
Public Member Functions | ||||||||||||||||
__invoke (ContainerInterface $container, $requestedName, array $options=null) | ||||||||||||||||
Create an object.
| ||||||||||||||||
canCreate (ContainerInterface $container, $requestedName) | ||||||||||||||||
Can the factory create an instance for the service?
| ||||||||||||||||
Protected Attributes | |
$aliases | |
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.
__invoke | ( | ContainerInterface | $container, |
$requestedName, | |||
array | $options = null |
||
) |
Create an object.
ContainerInterface | $container | |
string | $requestedName | |
null | array | $options |
ServiceNotFoundException | if unable to resolve the service. |
ServiceNotCreatedException | if an exception is raised when creating a service. |
ContainerException | if any other error occurs |
Implements FactoryInterface.
canCreate | ( | ContainerInterface | $container, |
$requestedName | |||
) |
Can the factory create an instance for the service?
ContainerInterface | $container | |
string | $requestedName |
Implements AbstractFactoryInterface.
|
protected |