Last active
November 19, 2022 21:17
-
-
Save dgafka/c86dabc6369856c3dd9848a1af76667f to your computer and use it in GitHub Desktop.
testing-message-driven-architecture-in-php-01
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class OrderService | |
{ | |
#[CommandHandler] | |
public function place(PlaceOrder $placeOrder, OrderRepository $orderRepository, EventBus $eventBus): void | |
{ | |
$orderRepository->save(Order::from($placeOrder)); | |
$eventBus->publish(new OrderWasPlaced($placeOrder->getOrderId()), []); | |
} | |
} | |
class OrderNotifier | |
{ | |
#[Asynchronous('notifications')] | |
#[EventHandler(endpointId: "order_notifier")] | |
public function place(OrderWasPlaced $orderWasPlaced, NotificationService $notificationService): void | |
{ | |
$notificationService->notifyAboutOrder($orderWasPlaced); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment