src/AppBundle/Command/CountOnlineCommand.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace AppBundle\Command;
use Topxia\Service\Common\ServiceKernel;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class CountOnlineCommand extends BaseCommand
{
protected function configure()
{
$this->setName('util:count-online')
->addArgument('type', InputArgument::REQUIRED, 'type的值是枚举类型:login, total')
->addArgument('minute', InputArgument::REQUIRED, '分钟');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->initServiceKernel();
$type = $input->getArgument('type');
if (!in_array($type, array('login', 'total'))) {
$output->writeln('type参数不正确,type的值是枚举类型:login, total');
return;
}
$minute = $input->getArgument('minute');
$currentTime = time();
$start = $currentTime - $minute * 60;
$count = 0;
if ('login' == $type) {
$count = $this->getStatisticsService()->countLogin($start);
} elseif ('total' == $type) {
$count = $this->getStatisticsService()->countOnline($start);
}
$output->write($count);
}
protected function getStatisticsService()
{
return ServiceKernel::instance()->createService('System:StatisticsService');
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。