| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Yatra\Hooks; |
| 6 |
|
| 7 |
use Yatra\Services\TripLifecycleCronService; |
| 8 |
|
| 9 |
/** |
| 10 |
* CronHooks |
| 11 |
* Registers and runs scheduled tasks (trip lifecycle, etc.). |
| 12 |
*/ |
| 13 |
class CronHooks |
| 14 |
{ |
| 15 |
/** |
| 16 |
* Initialize cron-related hooks. |
| 17 |
*/ |
| 18 |
public static function init(): void |
| 19 |
{ |
| 20 |
// Ensure lifecycle cron is scheduled (in case activation missed) |
| 21 |
add_action('init', [TripLifecycleCronService::class, 'registerCronHook']); |
| 22 |
|
| 23 |
// Daily handler |
| 24 |
add_action(TripLifecycleCronService::CRON_HOOK, function () { |
| 25 |
(new TripLifecycleCronService())->runDaily(); |
| 26 |
}); |
| 27 |
} |
| 28 |
} |
| 29 |
|