* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ declare(strict_types=1); namespace PrestaShop\CircuitBreaker\Transition; use PrestaShop\CircuitBreaker\Contract\TransitionDispatcherInterface; use PrestaShop\CircuitBreaker\Event\TransitionEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class EventDispatcher implements the TransitionDispatcher using the Symfony EventDispatcherInterface */ class EventDispatcher implements TransitionDispatcherInterface { /** * @var EventDispatcherInterface the Symfony Event Dispatcher */ private $eventDispatcher; public function __construct(EventDispatcherInterface $eventDispatcher) { $this->eventDispatcher = $eventDispatcher; } /** * {@inheritdoc} */ public function dispatchTransition(string $transition, string $service, array $serviceParameters): void { $event = new TransitionEvent($transition, $service, $serviceParameters); $this->eventDispatcher->dispatch($transition, $event); } }