0 follower

Abstract Class Yiisoft\Queue\Middleware\MiddlewareFactory

InheritanceYiisoft\Queue\Middleware\MiddlewareFactory
SubclassesYiisoft\Queue\Middleware\Consume\ConsumeMiddlewareFactory, Yiisoft\Queue\Middleware\FailureHandling\FailureMiddlewareFactory, Yiisoft\Queue\Middleware\Push\PushMiddlewareFactory

Protected Properties

Hide inherited properties

Property Type Description Defined By
$container \Psr\Container\ContainerInterface Yiisoft\Queue\Middleware\MiddlewareFactory

Property Details

Hide inherited properties

$container protected property
protected \Psr\Container\ContainerInterface $container null

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Psr\Container\ContainerInterface $container, Yiisoft\Queue\Middleware\CallableFactory $callableFactory )
$container \Psr\Container\ContainerInterface
$callableFactory Yiisoft\Queue\Middleware\CallableFactory

                public function __construct(
    protected readonly ContainerInterface $container,
    private readonly CallableFactory $callableFactory,
) {}

            
create() protected method

protected \Yiisoft\Queue\Middleware\T create ( callable|array|string $definition )
$definition callable|array|string

Middleware definition in one of the following formats:

return \Yiisoft\Queue\Middleware\T

Middleware instance

throws Yiisoft\Queue\Middleware\InvalidMiddlewareDefinitionException

                protected function create(callable|array|string $definition): object
{
    try {
        $callable = $this->callableFactory->create($definition);
        return $this->wrapMiddleware($callable);
    } catch (InvalidCallableConfigurationException) {
        // Not a callable, try internal checks
    }
    if (is_string($definition)) {
        return $this->getFromContainer($definition);
    }
    if (is_array($definition)) {
        return $this->tryGetFromArrayDefinition($definition)
            ?? throw new InvalidMiddlewareDefinitionException($definition);
    }
    throw new InvalidMiddlewareDefinitionException($definition);
}

            
getInterfaceName() protected abstract method

protected abstract class-string<\Yiisoft\Queue\Middleware\T> getInterfaceName ( )
return class-string<\Yiisoft\Queue\Middleware\T>

Required interface FQCN

                abstract protected function getInterfaceName(): string;

            
wrapMiddleware() protected abstract method

protected abstract \Yiisoft\Queue\Middleware\T wrapMiddleware ( callable $callback )
$callback callable

Callable to wrap

return \Yiisoft\Queue\Middleware\T

Wrapped middleware

                abstract protected function wrapMiddleware(callable $callback): object;