PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.14.2
Yatra – Travel Booking & Tour Operator Software v3.0.14.2
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 2.0.10 All 83 releases
yatra / app / Services / DepartureCronService.php

DepartureCronService.php in Yatra – Travel Booking & Tour Operator Software 3.0.14.2, at app/Services/DepartureCronService.php

59 lines 1.4 KB
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\Services;
6
7 use Yatra\Repositories\DepartureRepository;
8
9 /**
10 * Departure Cron Service
11 * Handles daily cron job tasks for departure status updates
12 */
13 class DepartureCronService
14 {
15 private DepartureRepository $repository;
16
17 public function __construct()
18 {
19 $this->repository = new DepartureRepository();
20 }
21
22 /**
23 * Daily cron job handler
24 * Updates statuses for all departures:
25 * - Marks past departures (end_date < today)
26 * - Marks full departures (booked_count >= max_capacity)
27 * - Marks upcoming departures (otherwise)
28 *
29 * Note: Uses end_date to determine if trip is complete (past)
30 */
31 public function dailyStatusUpdate(): void
32 {
33 $updated = $this->repository->recalculateAllStatuses();
34
35 }
36
37 /**
38 * Register WordPress cron hook
39 */
40 public static function registerCronHook(): void
41 {
42 if (!wp_next_scheduled('yatra_daily_departure_status_update')) {
43 wp_schedule_event(time(), 'daily', 'yatra_daily_departure_status_update');
44 }
45 }
46
47 /**
48 * Unregister WordPress cron hook
49 */
50 public static function unregisterCronHook(): void
51 {
52 $timestamp = wp_next_scheduled('yatra_daily_departure_status_update');
53 if ($timestamp) {
54 wp_unschedule_event($timestamp, 'yatra_daily_departure_status_update');
55 }
56 }
57 }
58
59