我一直在開發一個匯入 JSON 的擴展,制作一個包含所需內容的 PHP 陣列并使用 external_import 匯入它。這是一個將與 Cronjob 一起運行的命令。
目前,我從 external_import 收到 2 個不同的錯誤(我不知道錯誤為什么會改變)。
未找到請求的配置(表:tx_something_domain_model_formation,索引:0)。訊息:無法寫入臨時快取檔案“ thisisthepathtothewebsites /typo3temp/var/Cache/Data/l10n/61794fcc21579208003962.temp”。[1334756737]
或者
用戶沒有足夠的權限同步表 tx_something_domain_model_formation。
以下是命令類中的方法
protected function configure()
{
$this->setDescription('Synchroniser les formations externe dans typo3.');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$arrayFormations = $this->getFormations();
$message = $this->importFormation($arrayFormations);
print_r($message);
$io->writeln('Test');
return 0;
}
private function getFormations(){
$jsonPartOne = json_decode(file_get_contents(PATH_typo3conf . "ext/something/Ressources/Private/Assets/Json/apiPage1.json"), true);
$jsonPartTwo = json_decode(file_get_contents(PATH_typo3conf . "ext/something/Ressources/Private/Assets/Json/apiPage2.json"), true);
$jsonFormations = array_merge($jsonPartOne['elements'], $jsonPartTwo['elements']);
return $jsonFormations;
}
private function importFormation(array $formations){
if(count($formations) === 0){
//TODO Erreur
return;
}
$dataFormations = [];
$dataGroupe = [];
$dataformateurs = [];
$dataFormationsGroupes = [];
foreach ($formations as $formation){
$dataFormations[] = [
'id_formation' => $formation['idFormation'],
'nom' => $formation['nom'],
'description' => $formation['description']['texteHtml'],
'duree' => $formation['dureeFormation']['dureeEnHeures'],
];
}
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
$importer = $objectManager->get(\Cobweb\ExternalImport\Importer::class);
$importer->getExtensionConfiguration();
$importer->setContext('cli');
$importer->setDebug(true);
$importer->setVerbose(true);
return $importer->import('tx_something_domain_model_formation', 0, $dataFormations);
}
uj5u.com熱心網友回復:
我可能已經找到了解決方案。
添加此Bootstrap::getInstance()->initializeBackendAuthentication();行使其有效。它用TYPO3\CMS\Core\Core\Bootstrap;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/343626.html
標籤:php symfony 错别字3 外部数据库 打字3-8.x
上一篇:每次遷移都會改變uuid列的學說
