Change storage pid when programmatically persisting a model

房东的猫 提交于 2019-12-25 04:56:23

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!