Project

General

Profile

Actions

Bug #70960

closed

ActionController::setViewConfiguration() / StandaloneView::set*() is not resolving 'EXT:' in plugin.*.view.*rootPaths

Added by Klaus Bitto over 8 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
Fluid
Target version:
-
Start date:
2015-10-22
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Having a TS configuration like:

plugin.tx_bla {
    persistence {
        ...
    }
    settings {
        ...
    }
    view {
        partialRootPaths {
            10 = EXT:tx_bla/Resources/Private/Partials/
        }
    }
}

In my ActionController derivate, I create an Standalone View to render an email:

/** @var StandaloneView $emailNotificationView */
$emailNotificationView = $this->objectManager->get(StandaloneView::class);
$this->setViewConfiguration($emailNotificationView); // e.g. [ 10 => 'EXT:tx_bla/Resources/Private/Partials/' ]
$emailNotificationView->setTemplatePathAndFilename($notificationRecipientConfiguration['template']); // e.g. EXT:bla/Resources/Private/Templates/Notification/Admin/OnFailure.html

Now, I would expect that either ActionController::setViewConfiguration(), or even better all of StandaloneView::setTemplatePathAndFilename(), StandaloneView::setLayoutRootPaths() and StandaloneView::setPartialRootPaths() call GeneralUtility::getFileAbsFileName() on the submitted values, so that 'EXT:bla' can be resolved into a proper path.

When calling StandaloneView::setTemplatePathAndFilename(), I can of course do this manually.
But when calling ActionController::setViewConfiguration(), then I would very much need to be able to expect that a setting of plugin.tx_bla.view.partialRootPaths.10 = EXT:tx_bla/Resources/Private/Partials/ is resulting in a succesful rendering of an <f:render partial="PartialName" /> tag.
However, within \TYPO3\CMS\Fluid\ViewHelpers\RenderViewHelper::render(), \TYPO3\CMS\Fluid\View\StandaloneView::getPartialPathAndFilename() throws a InvalidTemplateResourceException('Could not load partial file. Tried following paths: "' . implode('", "', $possiblePartialPaths) . '".', 1288092556);, since the 'EXT:' reference is not resolved anywhere. Specifically, \TYPO3\CMS\Fluid\View\StandaloneView::testFileExistence() returns FALSE, since is_file() is called with an unprocessed path.

My current workaround is overriding these methods within a custom StandaloneView:

use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
 * StandaloneView, overriding to allow use of e.g. "EXT:" in template/partial/layout paths
 *
 * @package Netcreators\Bla
 * @author Klaus Bitto <klaus@netcreators.nl>
 */
class StandaloneView extends \TYPO3\CMS\Fluid\View\StandaloneView {

    /**
     * @param string $templatePathAndFilename
     */
    public function setTemplatePathAndFilename($templatePathAndFilename) {
        $this->templatePathAndFilename = GeneralUtility::getFileAbsFileName($templatePathAndFilename);
    }

    /**
     * @param array $layoutRootPaths
     */
    public function setLayoutRootPaths(array $layoutRootPaths) {
        foreach($layoutRootPaths as &$layoutRootPath) {
            $layoutRootPath = GeneralUtility::getFileAbsFileName($layoutRootPath);
        }
        $this->layoutRootPaths = $layoutRootPaths;
    }

    /**
     * @param array $partialRootPaths
     */
    public function setPartialRootPaths(array $partialRootPaths) {
        foreach($partialRootPaths as &$partialRootPath) {
            $partialRootPath = GeneralUtility::getFileAbsFileName($partialRootPath);
        }
        $this->partialRootPaths = $partialRootPaths;
    }
}

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Feature #69863: Use new standalone Fluid as composer dependencyClosedClaus Due2015-09-16

Actions
Actions

Also available in: Atom PDF