问题
I'm quite new to Extbase and I'm trying to programmatically persist a new Model. The following code works:
$testModel = $this->objectManager->create('Tx_MyExtension_Domain_Model_Test');
$testModel->setName('testing');
$this->TestRepository->add($testModel);
$this->persistenceManager->persistAll();
However, I would like to change the storage folder it is put in (thus; change the pid field the record gets in the database). How should I do this?
回答1:
You can set the default storage pid for new entries for a specific model in the typoscript setup of your extension:
plugin.tx_your_extension {
persistence {
classes {
Tx_YourExtension_Domain_Model_YourModel.newRecordStoragePid = 74
}
}
}
Now all new models are saved in this location.
来源:https://stackoverflow.com/questions/15141992/change-storage-pid-when-programmatically-persisting-a-model