Class ReflectionBasedAbstractFactory

Summary

Fully Qualified Name: Laminas\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory
Implements: AbstractFactoryInterface

Description

Reflection-based factory.

To ease development, this factory may be used for classes 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:

'service_manager' => [

'abstract_factories' => [
    ReflectionBasedAbstractFactory::class,
],

],

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

'service_manager' => [

'factories' => [
    MyClassWithDependencies::class => ReflectionBasedAbstractFactory::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.

Based on the LazyControllerAbstractFactory from laminas-mvc.

Methods

Name Description Defined By
__construct() Constructor. ReflectionBasedAbstractFactory
__invoke() {@inheritDoc} ReflectionBasedAbstractFactory
canCreate() {@inheritDoc} ReflectionBasedAbstractFactory

Method Details

__construct()

Constructor.

Allows overriding the internal list of aliases. These should be of the form class name => well-known service name; see the documentation for the $aliases property for details on what is accepted.

Parameter Name Type Description
$aliases string[]

Returns:

__invoke()

{@inheritDoc}

Parameter Name Type Description
$container
$requestedName
$options

Returns: \DispatchableInterface

canCreate()

{@inheritDoc}

Parameter Name Type Description
$container
$requestedName

Returns:

Top