for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
*
* Copyright (c) 2024 Mykhailo Shtanko [email protected]
* For the full copyright and license information, please view the LICENSE.MD
* file that was distributed with this source code.
*/
namespace FRZB\Component\TransactionalMessenger\EventListener;
use FRZB\Component\TransactionalMessenger\Attribute\Transactional;
use FRZB\Component\TransactionalMessenger\Enum\CommitType;
use FRZB\Component\TransactionalMessenger\MessageBus\CommitTransactionInterface;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent;
#[AsEventListener(WorkerMessageHandledEvent::class, priority: Transactional::LISTENER_PRIORITY)]
class CommitTransactionOnMessageHandledEventListener
{
public function __construct(
private readonly CommitTransactionInterface $service,
) {}
public function __invoke(): void
$this->service->commit(...CommitType::cases());
}