clock->now(); $booking = $this->bookings->find_by_id( $booking_id ); if ( null === $booking ) { throw new DomainException( 'booking.not_found', 'Booking not found.' ); } $from = $booking->status(); if ( $from === $status ) { return $booking; } $updated = $this->tx->run( function () use ( $booking, $status, $now ): Booking { $booking->change_status( $status, $now ); $this->bookings->save( $booking, false ); return $booking; } ); $this->bus->dispatch( new BookingStatusChanged( (int) $updated->id(), $updated->uuid(), $from, $updated->status(), $now, $notify_customer ) ); return $updated; } }