0
我有以下模型:“Shelf”和“Book”,处于1:n关系。ExtBase:无法删除调度程序任务中的子对象
还有一个调度程序任务(扩展“调度程序”6.2.0)分析书籍并删除它们。调度程序任务分为两类:任务本身和业务逻辑。
任务:
namespace Vendor\MyExt\Scheduler;
class MultiStepProcessTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
public function execute() {
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$businessLogic = $objectManager->get(\Vendor\MyExt\Scheduler\MultiStepProcessTaskBusinessLogic::class);
return $businessLogic->run();
}
}
商业逻辑:
namespace Vendor\MyExt\Scheduler;
class MultiStepProcessTaskBusinessLogic {
public function run() {
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$shelvesRepository = $objectManager->get('Vendor\\MyExt\\Domain\\Repository\\ShelvesRepository');
$shelf = $shelvesRepository->findOneByLastFinishedTaskNumber(0);
$book = $shelf->getBooks()->current();
....
$shelf->removeBook($book);
$shelvesRepository->update($shelf);
return 1;
}
}
如果从我的扩展名为 - 一切都OK了:这本书被删除。 为了测试它,我把这些线变成一个控制器列表动作:
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$businessLogic = $objectManager->get(\Vendor\MyExt\Scheduler\MultiStepProcessTaskBusinessLogic::class);
$businessLogic->run();
如果被从调度器(如任务)的书不会被删除!仓库被创建,货架被提取,书被提取。但$shelf->removeBook($book);
完全没有效果。有人能解释我为什么吗?
我使用TYPO3版本6.2.19
太棒了!就是这样。非常感谢。 – firelex