51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* MineAdmin is committed to providing solutions for quickly building web applications
|
|
* Please view the LICENSE file that was distributed with this source code,
|
|
* For the full copyright and license information.
|
|
* Thank you very much for using MineAdmin.
|
|
*
|
|
* @Author X.Mo<root@imoi.cn>
|
|
* @Link https://gitee.com/xmo/MineAdmin
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
namespace Builder\Crontab;
|
|
|
|
|
|
class MineCrontabScheduler
|
|
{
|
|
/**
|
|
* MineCrontabManage
|
|
*/
|
|
protected MineCrontabManage $crontabManager;
|
|
|
|
/**
|
|
* \SplQueue
|
|
*/
|
|
protected \SplQueue $schedules;
|
|
|
|
/**
|
|
* MineCrontabScheduler constructor.
|
|
* @param MineCrontabManage $crontabManager
|
|
*/
|
|
public function __construct(MineCrontabManage $crontabManager)
|
|
{
|
|
$this->schedules = new \SplQueue();
|
|
$this->crontabManager = $crontabManager;
|
|
}
|
|
|
|
public function schedule(): \SplQueue
|
|
{
|
|
foreach ($this->getSchedules() ?? [] as $schedule) {
|
|
$this->schedules->enqueue($schedule);
|
|
}
|
|
return $this->schedules;
|
|
}
|
|
|
|
protected function getSchedules(): array
|
|
{
|
|
return $this->crontabManager->getCrontabList();
|
|
}
|
|
}
|