Ad

Sys_category In A Powermail Save Data Finisher

- 1 answer

i want to write powermail data in the data table of an own extbase extension. the form delivers a uid of a sys_category which i want to persist in my extension.

The relevant lines in my finisher:

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

this works as expected, the entries are persisted in the data table. But now i want to persist the given sys_category. This:

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

obvviously does not work ("expected parameter of type '\TYPO3\CMS\Extbase\Persistence\ObjectStorage', 'string' provided). I need to implement the ObjectStorage of sys_category but i don`t know how.

Very thankful for every hint ... !

Peter

Ad

Answer

You have to create a new instance of an ObjectStorage (e.g. $os = new ObjectStorage();) and now you can add an object to the objectStorage. After this you can use it in setCategories() function.

Ad
source: stackoverflow.com
Ad