src/Biz/Crontab/Service/Impl/CrontabServiceImpl.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Biz\Crontab\Service\Impl;
use Biz\Crontab\Service\CrontabService;
use Symfony\Component\Yaml\Yaml;
use Topxia\Service\Common\ServiceKernel;
class CrontabServiceImpl implements CrontabService
{
public function setNextExcutedTime($time)
{
if ($time >= $this->getNextExcutedTime()) {
return;
}
$filePath = $this->getCrontabConfigYml();
$yaml = new Yaml();
$content = $yaml->dump(array('crontab_next_executed_time' => $time));
$fh = fopen($filePath, 'w');
fwrite($fh, $content);
fclose($fh);
}
public function getNextExcutedTime()
{
$filePath = $this->getCrontabConfigYml();
$yaml = new Yaml();
if (!file_exists($filePath)) {
$content = $yaml->dump(array('crontab_next_executed_time' => 0));
$fh = fopen($filePath, 'w');
fwrite($fh, $content);
fclose($fh);
}
$fileContent = file_get_contents($filePath);
$config = $yaml->parse($fileContent);
return $config['crontab_next_executed_time'];
}
private function getCrontabConfigYml()
{
return ServiceKernel::instance()->getParameter('kernel.root_dir').'/../app/data/crontab_config.yml';
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。