简体   繁体   English

Typo3为CommandController命令定义storagePid

[英]Typo3 Define storagePid for CommandController command

I would like to import different data using a CommandController (scheduler). 我想使用CommandController(调度程序)导入不同的数据。 I allready figured out that it is possible to set a global storagePid like: 我已经想通了,可以像这样设置一个全局的storagePid:

module.tx_myextension.persistence.storagePid = 123

source: https://worksonmymachine.org/blog/commandcontroller-and-storagepid 来源: https : //worksonmymachine.org/blog/commandcontroller-and-storagepid

That works fine, but my extension contains multiple models which should be saved on different Pid's 效果很好,但我的扩展程序包含多个模型,应保存在不同的Pid上

I also found an old post where someone said it is possible to define a pid for each model which would be exactly what I need: 我还发现了一个旧帖子,有人说可以为每个模型定义一个pid,而这正是我所需要的:

module.tx_myextension.persistence.classes.tx_myextension_domain_model_player.storagePid = 124
module.tx_myextension.persistence.classes.tx_myextension_domain_model_customer.storagePid = 125

source: https://typo3-german.typo3.narkive.com/WxjjtxXa/scheduler-storage-pid 来源: https : //typo3-german.typo3.narkive.com/WxjjtxXa/scheduler-storage-pid

But it seems like this lines get ignored. 但是似乎这些行被忽略了。 Is this the correct way or do I do something wrong? 这是正确的方法还是我做错了什么?

I am on TYPO3 6.2.44 我正在使用TYPO3 6.2.44

I suggest to create params for the controller action. 我建议为控制器动作创建参数。 For each model a storage pid. 对于每个模型,一个存储pid。

so you have myCommand($domain1Pid, $domain2Pid,$domain3Pid, ...) 所以你有myCommand($domain1Pid, $domain2Pid,$domain3Pid, ...)

Now as first call in your function you get the querySettings for the repositories and apply the storage pids: 现在,作为函数的第一个调用,您将获得存储库的querySettings并应用存储pid:

$querySettings = $this->domain1Repository->createQuery()->getQuerySettings();
$querySettings->setStoragePageIds([$domain1Pid]);
$this->domain1Repository->setDefaultQuerySettings($querySettings);

repeat this for each repository. 对每个存储库重复此操作。 In the scheduler job settings or cli you can now define the pids for each storage. 在调度程序作业设置或CLI中,您现在可以为每个存储定义pid。

btw: you can also use $domain->setPid(123) to set the pid of each model where to save. 顺便说一句:您还可以使用$domain->setPid(123)来设置每个模型的pid保存位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM