首页 > 解决方案 > powermail 保存数据整理器中的 sys_category

问题描述

我想在自己的 extbase 扩展的数据表中写入 powermail 数据。该表单提供了一个 sys_category 的 uid,我希望将其保留在我的扩展程序中。

我的整理器中的相关行:

$obj = GeneralUtility::makeInstance('Vendor\myExt\Domain\Model\ProductRating');
$obj->setName('Huber');
$obj->setPrename('Hans');
// etc.
$this->persistenceManager->add($obj);
$this->persistenceManager->persistAll();

这按预期工作,条目保留在数据表中。但现在我想保留给定的 sys_category。这个:

$obj->setCategories(13);  // 13 is the uid of the category

显然不起作用(“类型为'\TYPO3\CMS\Extbase\Persistence\ObjectStorage'的预期参数,'string'提供)。我需要实现sys_category的ObjectStorage,但我不知道如何。

非常感谢每一个提示......!

彼得

标签: typo3extbasetypo3-8.x

解决方案


您必须创建一个 ObjectStorage 的新实例(例如 $os = new ObjectStorage();),现在您可以向 objectStorage 添加一个对象。在此之后,您可以在 setCategories() 函数中使用它。


推荐阅读