簡體   English   中英

typo3忽略storagePid

[英]typo3 ignores storagePid

我嘗試使用調度程序任務構建導入程序。

該任務將創建一個對象管理器,該對象管理器將創建我的導入服務。 此導入服務對存儲庫具有依賴性。

我只是創建實例並將它們添加到存儲庫中。

在我嘗試指定應將記錄保存在哪個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

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

我發現了一個丑陋的方法。 通過調度程序執行服務時,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'
));

我按照lorenz 在extbase擴展中的建議使用ImportCommandController,如何從調度程序任務訪問持久層? (與此同時,我的實際代碼已更改,請告訴我是否需要)

而且我必須手動設置pid:

$item->setPid($storagePid);

有一個簡單的技巧

在您的ts中添加類似的內容

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

這樣您就可以在代碼中可以訪問ts的任何地方訪問存儲pid。 例如在控制器中

$this->settings['storagePid']

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM