首页 文章

TYPO3 8.7 Extbase生成csv文件

提问于
浏览
0

我尝试在我的TYPO3扩展中生成一个csv文件 . 我收到以下错误:

1225709595:无法加载Fluid模板文件“” . (更多信息)

在第719行的文件/usr/local/www/apache24/xx/xx/vendor/typo3fluid/fluid/src/View/TemplatePaths.php中抛出TYPO3Fluid \ Fluid \ View \ Exception \ InvalidTemplateResourceException .

25 TYPO3Fluid \ Fluid \ View \ TemplatePaths :: resolveFileInPaths(array,“Default”,“csv”)

我的控制器看起来像:

$icalView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
                $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);

$ icalView-> setFormat( 'CSV');

$icalView->setTemplatePathAndFilename('typo3conf/ext/xxx/Resources/Private/Templates/Bestellung/Listbestellungen.txt'); 

                $icalView->assign('xx', $xx);

                $icalContent = $icalView->render();

我在... Bestellung /中有Subfolter“Layout”,我的文件Default.csv

在TYPO3 7.6.x中扩展的相同代码 - 8.7中有哪些变化?

感谢帮助!马丁

2 回答

  • 0

    这是一个片段,我是如何在8.7中发送电子邮件的:

    据我所知,在选择要使用的模板之前,还必须设置模板,布局和部分的路径

    /**
     * configurationManager
     *
     * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManager
     * @inject
     */
    protected $configurationManager;
    
    public function sendEmail($template,...)
    {
        /**
         * Generate Email Body
         */
    
        $extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
    
        /** @var StandaloneView $emailView */
        $emailView = $this->objectManager->get(StandaloneView::class);
        $emailView->getRequest()->setControllerExtensionName($controllerExtensionName);
        $emailView->getRequest()->setPluginName($pluginName);
        $emailView->getRequest()->setControllerName($controllerName);
    
        $emailView->setTemplateRootPaths($extbaseFrameworkConfiguration['view']['templateRootPaths']);
        $emailView->setLayoutRootPaths($extbaseFrameworkConfiguration['view']['layoutRootPaths']);
        $emailView->setPartialRootPaths($extbaseFrameworkConfiguration['view']['partialRootPaths']);
    
        $emailView->setTemplate('Email/' . ucfirst($template));
        $emailView->assignMultiple($variables);
    
        $emailBody = $emailView->render();
    }
    
  • 1

    我通过稍微更改代码解决了这个问题,现在它正在工作:

    $storage = $this->resourceFactory->getDefaultStorage();
                    if ($storage === NULL) {
                        throw new \RuntimeException('Could not get the default storage', 1475590001);
                    }
    
    
    
    
                    /** @var \TYPO3\CMS\Fluid\View\StandaloneView $icalView */
                    $icalView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
                    $icalView->setFormat('csv');
    
                    $templateRootPath[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:xxx/Resources/Private/Templates/');
                    $layoutRootPaths[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:xxx/Resources/Private/Layouts/');
                    $partialRootPaths[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:xxx/Resources/Private/Partials/');
    
                    $icalView->setLayoutRootPaths($layoutRootPaths);
                    $icalView->setPartialRootPaths($partialRootPaths);
                    $icalView->setTemplatePathAndFilename('typo3conf/ext/xxx/Resources/Private/Templates/Bestellung/Listbestellungen.txt');
    
                    $icalView->assign('xxx', $xxx);
    
                    $icalContent = $icalView->render();
    
                    $tempFolder = $storage->getFolder('bestellungencsv');
                    $tempFile = $storage->createFile('bestellungen_'.$xxx->getUid().'.csv', $tempFolder);
                    $tempFile->setContents($icalContent);
    

相关问题