0

Final Class Yiisoft\Queue\Middleware\CallableFactory

InheritanceYiisoft\Queue\Middleware\CallableFactory

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Queue\Middleware\CallableFactory
create() Create a real callable listener from definition. Calling the returned callable invokes the resolved listener, injecting its dependencies by type hinting. Yiisoft\Queue\Middleware\CallableFactory

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Psr\Container\ContainerInterface $container, ?\Psr\Container\ContainerInterface $dependencyContainer = null )
$container \Psr\Container\ContainerInterface
$dependencyContainer ?\Psr\Container\ContainerInterface

                public function __construct(
    private readonly ContainerInterface $container,
    ?ContainerInterface $dependencyContainer = null,
) {
    $this->injector = new Injector($dependencyContainer ?? $container);
}

            
create() public method

Create a real callable listener from definition. Calling the returned callable invokes the resolved listener, injecting its dependencies by type hinting.

public callable create ( mixed $definition )
$definition mixed

Definition to create listener from.

throws Yiisoft\Queue\Middleware\InvalidCallableConfigurationException

Failed to create listener.

throws \Psr\Container\ContainerExceptionInterface

Error while retrieving the entry from container.

                public function create(mixed $definition): callable
{
    $callable = $this->resolve($definition);
    return fn(mixed ...$params): mixed => $this->injector->invoke($callable, $params);
}