Hello.
I wanted to get the absolute path of a file from the filesystem perspective but found no way to get this with the current API of the resourceManager.
I know you can get the Webserver URL to a resource with $this->resourceManager->getPublicPackageResourceUriByPath()
But there is no method to somehow get the filepath.
You can get the file content with file_get_contents(), so i tried different php functions like realpath() which only returns false since i guess it does not use Stream Wrappers like file_get_contents does.
I currently have written this method to get the path
Usecase was giving ImageMagick the path to a font-file. since you can only give it by a path, i was looking for any easy solution.
Didn’t thought about the PackageManager and migt be useful.
But i thought it might be possible to get the filesystem path by a resource uri like resource://My.Package/Foo/Bar.file
since we can already use it with file_get_contents() , give it to viewHelpers etc. it could have been useful.
Problem with resources is that they may be not on the system at all when cloudstorage is used (at least the public path can be anywhere). I would suggest to use file_get_contents to create a tempfile that is passed to imagemagick.
Other than that the package manager is able to tell you the full resources-path of the package via $package->getResourcesPath().