‪TYPO3CMS  11.5
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 string resolveExtensionPath (array $arguments, RenderingContextInterface $renderingContext)
 
static string resolveExtensionKey (array $arguments, RenderingContextInterface $renderingContext)
 
static RequestInterface resolveValidatedRequest (array $arguments, RenderingContextInterface $renderingContext)
 

Detailed Description

A ViewHelper for creating URIs to resources.

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 72 of file ResourceViewHelper.php.

Member Function Documentation

◆ initializeArguments()

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

Definition at line 75 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 89 of file ResourceViewHelper.php.

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

◆ resolveExtensionKey()

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

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

Parameters
array$arguments
RenderingContextInterface$renderingContext
Returns
‪string

Definition at line 127 of file ResourceViewHelper.php.

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

◆ resolveExtensionPath()

static string 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

Parameters
array$arguments
RenderingContextInterface$renderingContext
Returns
‪string

Definition at line 106 of file ResourceViewHelper.php.

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

◆ resolveValidatedRequest()

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

Resolves and validates the request from rendering context

Parameters
array$arguments
RenderingContextInterface$renderingContext
Returns
‪RequestInterface

Definition at line 144 of file ResourceViewHelper.php.

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