【发布时间】:2019-04-15 07:23:46
【问题描述】:
嘿,伙计们,我想知道如何做一个 cron 选项卡,但该 cron 选项卡必须更新数据库,所以我需要
$this->getDoctrine()->getManager()
但是为此我需要扩展Controller,但我已经扩展了Command
所以我有办法扩展两者吗?我必须使用 sql 命令吗?或者使用 cron 选项卡更新数据库的其他方式?
在这里你可以找到我的发现,看看我需要什么:
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class MessageController extends Command
{
protected function configure () {
$this->setName('app:notification');
$this->setDescription("Permet juste d'envoyer les notifications");
$this->setHelp("Je serai affiche si on lance la commande app/console app:notification -h");
}
public function execute (InputInterface $input, OutputInterface $output) {
//HERE I WANT TO DO : $this->getDoctrine()->getManager();
$output->writeln('!');
}
}
【问题讨论】: