typo3 - 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,但我不知道如何。
非常感谢每一个提示......!
彼得
解决方案
您必须创建一个 ObjectStorage 的新实例(例如 $os = new ObjectStorage();),现在您可以向 objectStorage 添加一个对象。在此之后,您可以在 setCategories() 函数中使用它。
推荐阅读
- google-sheets-formula - 使用公式将天转换为周,然后是月,然后是年
- python - 在 A* 搜索中计算自定义成本函数
- python - MEXOR Codechef 十月挑战
- ruby-on-rails - 返回子类常量数组的不同元素
- java - org.springframework.http.converter.HttpMessageNotReadableException:缺少所需的请求正文 Spring boot 项目
- css - CSS卡片翻转效果——如何让它每次点击都向同一个方向翻转?
- google-data-studio - 将数据源从一个连接器迁移到另一个连接器
- spring-batch - Spring-Batch Reader 在 excel 中读取多张工作表
- python - ValueError:错误的项目数通过 3,位置暗示 1
- javascript - 如何删除数组的某个项目?