Created
June 28, 2019 19:52
-
-
Save wuestkamp/710a24672103394c2c891bbf2e0d0e4d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 declare(strict_types=1); | |
| ... | |
| class BookingManager | |
| { | |
| private $messageBus; | |
| private $bookingRepository; | |
| public function __construct(MessageBusInterface $messageBus, BookingRepository $bookingRepository) | |
| { | |
| $this->messageBus = $messageBus; | |
| $this->bookingRepository = $bookingRepository; | |
| } | |
| public function createBooking(string $name): void | |
| { | |
| $booking = new Booking($name); | |
| $this->bookingRepository->save($booking); | |
| $this->messageBus->dispatch(new CreateBookingMessage($booking->getId())); | |
| } | |
| public function findBooking(int $bookingId): ?Booking | |
| { | |
| return $this->bookingRepository->findOneById($bookingId); | |
| } | |
| public function processBooking(Booking $booking): void | |
| { | |
| sleep(5); // this action takes long! | |
| $booking->setStatus(Booking::STATUS_CREATED); | |
| $this->bookingRepository->save($booking); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment