| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Yatra\Core\Handlers; |
| 6 |
|
| 7 |
use Yatra\Repositories\BookingRepository; |
| 8 |
|
| 9 |
/** |
| 10 |
* Booking Confirmation Page Handler |
| 11 |
* |
| 12 |
* Handles booking confirmation page requests |
| 13 |
*/ |
| 14 |
class BookingConfirmationPageHandler extends BasePageHandler |
| 15 |
{ |
| 16 |
/** |
| 17 |
* Handle booking confirmation page request |
| 18 |
* |
| 19 |
* @param array $route_data Route data from RouteMatcher |
| 20 |
* @return bool True if handled successfully |
| 21 |
*/ |
| 22 |
public function handle(array $route_data): bool |
| 23 |
{ |
| 24 |
$confirmation_id = (string) ($route_data['confirmation_id'] ?? ''); |
| 25 |
|
| 26 |
$bookingRepo = new BookingRepository(); |
| 27 |
$booking = $bookingRepo->findByConfirmationSegment($confirmation_id); |
| 28 |
|
| 29 |
if (!$booking) { |
| 30 |
return false; |
| 31 |
} |
| 32 |
|
| 33 |
// Configure $wp_query + virtual WP_Post so FSE block themes don't fall back to 404.html. |
| 34 |
$this->setupPageEnvironment('singular', [ |
| 35 |
'title' => __('Booking Confirmation', 'yatra'), |
| 36 |
'object_id' => (int) ($booking->id ?? 0), |
| 37 |
'post_type' => 'page', |
| 38 |
'post_name' => $confirmation_id, |
| 39 |
]); |
| 40 |
|
| 41 |
// Set up global booking object |
| 42 |
$this->setGlobal('yatra_booking', $booking); |
| 43 |
|
| 44 |
// Set up query vars for backward compatibility |
| 45 |
$this->setQueryVars([ |
| 46 |
'yatra_booking_confirmation' => $confirmation_id, |
| 47 |
'yatra_booking' => $booking, |
| 48 |
]); |
| 49 |
|
| 50 |
return $this->selectTemplate('booking-confirmation', null, 'booking-confirmation'); |
| 51 |
} |
| 52 |
} |
| 53 |
|