[Flow] Resource Interceptors (for skin packages)

Steffen Wickham steffen at gaming-inc.de
Tue Apr 22 16:10:59 CEST 2014


Hi all,

I've got a question regarding Resource Interceptors in Fluid Views and
hope you can help me to understand the behaviour.

I created a new class (ClientTemplateView) which derives from standart
Fluid StandaloneView. ClientTemplateView loads the skin of the page from
another package, get the data assigned and display the result as Fluid
do it every time. Which package should be used is a value in the
Settings.yaml. Everything works fine till now except that resources
(Images, Stylesheets and so on) wouldn't be rewritten to the skin package.

So I had a look at the StandaloneView and overwrite the
buildParserConfiguration() in ClientTemplateView and set the default
package key to the skin Package for the Resource Interceptor. This is
how I implemented the buildParserConfiguration method
($this->skinPackageName is in "Vendor.Name" notation):
    protected function buildParserConfiguration() {
        $parserConfiguration =
$this->objectManager->get('TYPO3\Fluid\Core\Parser\Configuration');

        $resourceInterceptor =
$this->objectManager->get('TYPO3\Fluid\Core\Parser\Interceptor\Resource');
        $resourceInterceptor->setDefaultPackageKey(
$this->skinPackageName );

       
$parserConfiguration->addInterceptor($this->objectManager->get('TYPO3\Fluid\Core\Parser\Interceptor\Escape'));
        $parserConfiguration->addInterceptor($resourceInterceptor);

        return $parserConfiguration;
    }


When I initialize the view with the ActionRequest of my Controller, I
still get an URL to the main instead of the skin package. When I leave
the ActionRequest empty during initialization, the ResourceViewHelper
generates an invalid URL to my resource as there is no package key set,
e.g. "_Resources/Static/Packages//Images/myimage.jpg". However when I
set the package name as attribute for the ResourceViewHelper manually to
the Skin package, everything works fine.

Am I wrong using the interceptor as a proper way to determine the
resource path or have I to set the package key manually every time?
What is the interceptor for, when not for this purpose?

Greetings
Steffen


More information about the Flow mailing list