Final Class Yiisoft\Queue\Middleware\CallableFactory
| Inheritance | Yiisoft\Queue\Middleware\CallableFactory |
|---|
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Queue\Middleware\CallableFactory | |
| create() | Create a real callable listener from definition. | Yiisoft\Queue\Middleware\CallableFactory |
Method Details
| public mixed __construct ( \Psr\Container\ContainerInterface $container ) | ||
| $container | \Psr\Container\ContainerInterface | |
public function __construct(
private readonly ContainerInterface $container
) {
}
Create a real callable listener from definition.
| 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 = null;
if (is_string($definition) && $this->container->has($definition)) {
// Object with an __invoke() method
$callable = $this->container->get($definition);
}
if (is_array($definition)
&& array_keys($definition) === [0, 1]
&& is_string($definition[0])
&& is_string($definition[1])
) {
[$className, $methodName] = $definition;
$callable = $this->fromDefinition($className, $methodName);
}
if ($callable === null) {
$callable = $definition;
}
if (is_callable($callable)) {
return $callable;
}
throw new InvalidCallableConfigurationException();
}
Signup or Login in order to comment.