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