【问题标题】:typo3 ignores storagePid错字3 忽略 storagePid
【发布时间】:2015-03-09 12:34:01
【问题描述】:

我尝试使用调度程序任务构建导入器。

该任务创建了一个对象管理器,它创建了我的导入服务。 此导入服务依赖于存储库。

我只是创建实例并将它们添加到存储库中。

在我尝试指定我的记录应该保存在哪个 pid 上之前,它运行良好。我尝试在 setup.txt 中进行配置。

plugin.tx_extkey {
    view {
        templateRootPath = {$plugin.tx_extkey.view.templateRootPath}
        partialRootPath = {$plugin.tx_extkey.view.partialRootPath}
        layoutRootPath = {$plugin.tx_extkey.view.layoutRootPath}
    }
    persistence {
        storagePid = {$plugin.tx_extkey.persistence.storagePid}
        classes {
            EXTNAME\EXTNAME\Domain\Model\MODELNAME {
                newRecordStoragePid = {$plugin.tx_extkey.persistence.storagePid}
            }
        }
    }
    features {
        # uncomment the following line to enable the new Property Mapper.
        # rewrittenPropertyMapper = 1
    }
}

module.tx_extkey {
    persistence < plugin.tx_extkey.persistence
}

但这没有用。一切仍然保存到 pid 1

有没有我可能忽略的陷阱?

【问题讨论】:

  • pid 1 看起来像是从字符串转换而来的,而不是页面 ID。因此我怀疑变量没有设置。
  • 另一个可能的原因可能是错误的插件-“tx_extkey”实际上是“tx_extkey_pluginname”-因此,如果您使用多个插件,请确保为正确的插件配置内容(这实际上是我的问题; -) ) - 完整的文档在这里:docs.typo3.org/typo3cms/ExtbaseFluidBook/b-ExtbaseReference/…

标签: typo3 extbase typo3-6.2.x


【解决方案1】:

我发现了一个丑陋的方法。通过调度程序执行服务时,BackendConfigurationManager 没有获取 extensionName。在任务中手动设置它可以解决这个问题。

$objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');

/** @var BackendConfigurationManager $configurationManager */
$configurationManager = $objectManager->get('TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager');
$configurationManager->setConfiguration(array(
    'extensionName' => 'hnsenvionjob'
));

【讨论】:

    【解决方案2】:

    我使用了 lorenz 在In an extbase extension, how to access the persistence layer from a scheduler task? 中推荐的 ImportCommandController(我的实际代码在此期间已更改,如果需要,请告诉我)

    我必须手动设置 pid:

    $item-&gt;setPid($storagePid);

    【讨论】:

      【解决方案3】:

      有一个简单的技巧

      在你的 ts 中添加类似的东西

      plugin.tx_extkey.settings.storagePid = {$plugin.tx_extkey.persistence.storagePid}
      

      这将允许您在您可以访问您的 ts 的代码中的任何地方访问您的存储 pid。例如在控制器中

      $this->settings['storagePid']
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-02-26
        • 2012-05-28
        • 1970-01-01
        • 2023-01-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-23
        相关资源
        最近更新 更多