【问题标题】:use removeAll() in scheduler task在调度程序任务中使用 removeAll()
【发布时间】:2014-02-26 11:54:32
【问题描述】:

在做新的东西之前,我希望我的调度程序任务从数据库中删除所有条目,执行功能如下所示:

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;
}

将新条目插入数据库可以正常工作,但清除数据库根本不起作用。我做错了什么?

【问题讨论】:

    标签: typo3 scheduler extbase


    【解决方案1】:

    由于removeAll() 调用findAll()

    public function removeAll() {
            foreach ($this->findAll() AS $object) {
                $this->remove($object);
            }
        }
    

    很可能findAll() 不返回任何对象。你处理了存储 pid 吗?禁用它或手动传递它。如果您从调度程序上下文中使用存储库的方法,它不会只存在。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-14
    • 2018-04-28
    • 2012-10-06
    • 2016-03-19
    相关资源
    最近更新 更多