DigiComp.FlowSymfonyBridge..../Classes/MessageBusContainer.php
Ferdinand Kuhl 04ee933830
All checks were successful
ci/woodpecker/push/code-style Pipeline was successful
ci/woodpecker/push/functional-tests Pipeline was successful
Replacing annotations with attributes
2023-02-18 22:53:05 +01:00

34 lines
892 B
PHP

<?php
namespace DigiComp\FlowSymfonyBridge\Messenger;
use DigiComp\FlowSymfonyBridge\Messenger\ObjectManagement\RewindableGenerator;
use Neos\Flow\Annotations as Flow;
use Psr\Container\ContainerInterface;
use Symfony\Component\Messenger\MessageBus;
#[Flow\Scope('singleton')]
class MessageBusContainer implements ContainerInterface
{
#[Flow\InjectConfiguration(path: 'buses')]
protected array $configuration;
/**
* @var MessageBus[]
*/
protected array $buses = [];
public function get(string $id)
{
if (! isset($this->buses[$id])) {
$middlewares = new RewindableGenerator($this->configuration[$id]['middleware']);
$this->buses[$id] = new MessageBus($middlewares);
}
return $this->buses[$id];
}
public function has(string $id): bool
{
return isset($this->configuration[$id]);
}
}