以编程方式持久化模型时更改存储pid [英] Change storage pid when programmatically persisting a model

查看:68
本文介绍了以编程方式持久化模型时更改存储pid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Extbase还是很陌生,我正在尝试以编程方式坚持一个新模型.以下代码有效:

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();

但是,我想更改它放入的存储文件夹(因此;更改记录在数据库中获得的pid字段).我该怎么办?

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?

推荐答案

您可以在扩展程序的排印设置中为特定模型的新条目设置默认存储pid:

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.

这篇关于以编程方式持久化模型时更改存储pid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆