在做新的事情之前,我希望我的调度程序任务从数据库中删除所有条目,执行函数如下所示:
public function execute() {
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
$jobRepository = $objectManager->get('\TYPO3\MyExtension\Domain\Repository\JobRepository');
//clear DB
$jobRepository->removeAll();
(...)//insert new entries to DB
$objectManager->get('TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface')->persistAll();
return true;
}
向数据库插入新条目工作正常,但清除数据库根本不起作用。我究竟做错了什么?
Since removeAll()
calls findAll()
:
public function removeAll() {
foreach ($this->findAll() AS $object) {
$this->remove($object);
}
}
最有可能的findAll()
不返回任何对象。你处理过存储pid吗?要么禁用它,要么手动传递它。如果您从调度程序上下文中使用存储库的方法,它就不会在那里。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)