PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.11
Yatra – Travel Booking & Tour Operator Software v3.0.11
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
yatra / app / Hooks / SavedTripHooks.php

SavedTripHooks.php in Yatra – Travel Booking & Tour Operator Software 3.0.11, at app/Hooks/SavedTripHooks.php

39 lines 932 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Yatra\Hooks;
6
7 use Yatra\Repositories\SavedTripRepository;
8
9 /**
10 * Saved Trip (Wishlist) Hooks
11 *
12 * Keeps the wishlist meta in sync with the trip lifecycle: when a trip is
13 * deleted, its ID is purged from every user's saved-trips meta so orphan
14 * IDs don't accumulate forever.
15 */
16 class SavedTripHooks
17 {
18 public static function init(): void
19 {
20 add_action('yatra_trip_deleted', [self::class, 'onTripDeleted'], 10, 1);
21 }
22
23 /**
24 * Garbage-collect a deleted trip's ID from every user's wishlist.
25 */
26 public static function onTripDeleted($tripId): void
27 {
28 $tripId = (int) $tripId;
29 if ($tripId <= 0) {
30 return;
31 }
32 try {
33 (new SavedTripRepository())->removeTripFromAllUsers($tripId);
34 } catch (\Throwable $e) {
35 // Don't let cleanup failure break the trip-delete flow.
36 }
37 }
38 }
39