Fast Forward Container API

CallableFactory implements FactoryInterface

FinalYes

A factory that wraps a user-provided callable and executes it when invoked.

The callable MUST accept a PSR-11 ContainerInterface as its first and only argument. This factory SHALL be used when the construction logic must be fully delegated to a closure.

This class allows dynamic resolution of services using the container context.

Table of Contents

Interfaces

FactoryInterface
Defines a contract for service factories that rely on a PSR-11 container for instantiation.

Methods

__construct()  : mixed
Constructs a CallableFactory instance.
__invoke()  : mixed
Invokes the factory to create a service.

Methods

__construct()

Constructs a CallableFactory instance.

public __construct(callable $callable) : mixed
Parameters
$callable : callable

a callable that returns a service instance and accepts a container

__invoke()

Invokes the factory to create a service.

public __invoke(ContainerInterface $container) : mixed
Parameters
$container : ContainerInterface

the PSR-11 container for dependency resolution

Return values
mixed

the constructed service instance


        
On this page

Search results