Feature #33937

Convenience method to resolve public "resource://" paths

Added by Bastian Waidelich almost 10 years ago. Updated over 7 years ago.

Status:
Accepted
Priority:
Should have
Category:
Resource
Target version:
-
Start date:
2012-02-15
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

It would be helpful to have an easy way to resolve the 'resource://...' path
to static resources.
Currently we end up using code like the following a lot:

protected function resolveResourcePath($resourcePath) {
    $matches = array();
    preg_match('#resource://([^/]*)/Public/(.*)#', $resourcePath, $matches);
    if ($matches === array()) {
        throw new \TYPO3\Fluid\Core\ViewHelper\Exception('Resource path "' . $resourcePath . '" can\'t be resolved.', 1328543327);
    }
    $packageKey = $matches[1];
    $path = $matches[2];
    return $this->resourcePublisher->getStaticResourcesWebBaseUri() . 'Packages/' . $packageKey . '/' . $path;
}

Also available in: Atom PDF