1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 21:52:35 +01:00
invoiceninja/app/Services/Scheduler/SchedulerService.php

61 lines
1.2 KiB
PHP
Raw Normal View History

2023-01-08 06:15:33 +01:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-28 23:21:40 +01:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
2023-01-08 06:15:33 +01:00
*
* @license https://www.elastic.co/licensing/elastic-license
*/
2023-01-13 02:43:38 +01:00
namespace App\Services\Scheduler;
2023-01-08 06:15:33 +01:00
2023-02-17 22:36:51 +01:00
use App\Models\Scheduler;
2023-02-16 22:59:19 +01:00
use App\Utils\Traits\MakesDates;
2023-02-17 22:36:51 +01:00
use App\Utils\Traits\MakesHash;
2023-01-13 02:43:38 +01:00
2023-01-13 12:24:23 +01:00
class SchedulerService
2023-01-08 06:15:33 +01:00
{
2023-01-13 23:46:17 +01:00
use MakesHash;
2023-01-14 12:00:22 +01:00
use MakesDates;
2023-01-13 23:46:17 +01:00
private string $method;
2023-01-08 06:15:33 +01:00
2023-02-16 02:36:09 +01:00
public function __construct(public Scheduler $scheduler)
{
}
2023-01-08 06:15:33 +01:00
2023-01-13 23:46:17 +01:00
/**
* Called from the TaskScheduler Cron
2023-02-16 02:36:09 +01:00
*
* @return void
2023-01-13 23:46:17 +01:00
*/
public function runTask(): void
2023-01-08 06:15:33 +01:00
{
2023-03-18 08:24:56 +01:00
if (method_exists($this, $this->scheduler->template)) {
2023-03-08 07:43:52 +01:00
$this->{$this->scheduler->template}();
2023-03-18 08:24:56 +01:00
}
2023-01-13 23:46:17 +01:00
}
2023-03-21 22:00:20 +01:00
private function email_record()
2023-02-16 02:36:09 +01:00
{
2023-03-21 22:00:20 +01:00
(new EmailRecord($this->scheduler))->run();
2023-01-14 08:47:14 +01:00
}
2023-03-18 09:06:32 +01:00
private function email_statement()
2023-01-14 08:47:14 +01:00
{
2023-03-18 09:06:32 +01:00
(new EmailStatementService($this->scheduler))->run();
2023-01-13 23:46:17 +01:00
}
2023-03-18 09:06:32 +01:00
2023-01-17 10:48:10 +01:00
/**
* Sets the next run date of the scheduled task
2023-02-16 02:36:09 +01:00
*
2023-01-17 10:48:10 +01:00
*/
2023-01-17 09:42:34 +01:00
//handle when the scheduler has been paused.
2023-02-16 02:36:09 +01:00
}