‪TYPO3CMS  ‪main
TYPO3\CMS\Fluid\ViewHelpers\Uri\ResourceViewHelper Class Reference
Inheritance diagram for TYPO3\CMS\Fluid\ViewHelpers\Uri\ResourceViewHelper:

Public Member Functions

 initializeArguments ()
 

Static Public Member Functions

static string renderStatic (array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
 

Static Private Member Functions

static resolveExtensionPath (array $arguments, RenderingContextInterface $renderingContext)
 
static resolveExtensionKey (array $arguments, RenderingContextInterface $renderingContext)
 
static resolveValidatedRequest (array $arguments, RenderingContextInterface $renderingContext)
 

Detailed Description

A ViewHelper for creating URIs to resources.

This ViewHelper should be used for extension resource files.

For images within FAL storages, or where graphical operations are performed, use :ref:<f:uri.image> <typo3-fluid-uri-image> instead.

Examples

Best practice with EXT: syntax

::

<link href="{f:uri.resource(path:'EXT:indexed_search/Resources/Public/Css/Stylesheet.css')}" rel="stylesheet" >

Output::

<link href="typo3/sysext/indexed_search/Resources/Public/Css/Stylesheet.css" rel="stylesheet" >

Preferred syntax that works in both extbase and non-extbase context.

Defaults

::

<link href="{f:uri.resource(path:'Css/Stylesheet.css')}" rel="stylesheet" >

Output::

<link href="typo3conf/ext/example_extension/Resources/Public/Css/Stylesheet.css" rel="stylesheet" >

Works only in extbase context since it uses the extbase request to find current extension, magically adds 'Resources/Public' to path.

With extension name

::

<link href="{f:uri.resource(path:'Css/Stylesheet.css', extensionName: 'AnotherExtension')}" rel="stylesheet" >

Output::

<link href="typo3conf/ext/another_extension/Resources/Public/Css/Stylesheet.css" rel="stylesheet" >

Magically adds 'Resources/Public' to path.

Definition at line 79 of file ResourceViewHelper.php.

Member Function Documentation

◆ initializeArguments()

TYPO3\CMS\Fluid\ViewHelpers\Uri\ResourceViewHelper::initializeArguments ( )

Definition at line 82 of file ResourceViewHelper.php.

◆ renderStatic()

static string TYPO3\CMS\Fluid\ViewHelpers\Uri\ResourceViewHelper::renderStatic ( array  $arguments,
\Closure  $renderChildrenClosure,
RenderingContextInterface  $renderingContext 
)
static

Render the URI to the resource. The filename is used from child content.

Returns
‪string The URI to the resource
Exceptions
InvalidFileException

Definition at line 96 of file ResourceViewHelper.php.

References TYPO3\CMS\Core\Utility\PathUtility\getPublicResourceWebPath().

◆ resolveExtensionKey()

static TYPO3\CMS\Fluid\ViewHelpers\Uri\ResourceViewHelper::resolveExtensionKey ( array  $arguments,
RenderingContextInterface  $renderingContext 
)
staticprivate

Resolves extension key either from given extension name argument or from request

Definition at line 124 of file ResourceViewHelper.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\camelCaseToLowerCaseUnderscored(), and TYPO3\CMS\Fluid\ViewHelpers\Uri\ResourceViewHelper\resolveValidatedRequest().

◆ resolveExtensionPath()

static TYPO3\CMS\Fluid\ViewHelpers\Uri\ResourceViewHelper::resolveExtensionPath ( array  $arguments,
RenderingContextInterface  $renderingContext 
)
staticprivate

Resolves the extension path, either directly when possible, or from extension name and request

Definition at line 108 of file ResourceViewHelper.php.

References TYPO3\CMS\Core\Utility\PathUtility\isExtensionPath().

◆ resolveValidatedRequest()

static TYPO3\CMS\Fluid\ViewHelpers\Uri\ResourceViewHelper::resolveValidatedRequest ( array  $arguments,
RenderingContextInterface  $renderingContext 
)
staticprivate

Resolves and validates the request from rendering context

Definition at line 136 of file ResourceViewHelper.php.

Referenced by TYPO3\CMS\Fluid\ViewHelpers\Uri\ResourceViewHelper\resolveExtensionKey().