clock->now(); $booking = $this->bookings->find_by_id( $booking_id ); if ( null === $booking ) { throw new DomainException( 'booking.not_found', 'Booking not found.' ); } if ( null === $booking->hold_expires_at() && 'promoted' !== $reason ) { throw new DomainException( 'booking.not_a_hold', 'Booking is not a soft hold.' ); } $released = $this->tx->run( function () use ( $booking, $now ): Booking { $booking->cancel( CancelledBy::System, 'hold_released', $now ); $this->bookings->save( $booking, false ); return $booking; } ); $this->bus->dispatch( new HoldReleased( (int) $released->id(), $released->uuid(), $reason, $now ) ); return $released; } }