Pass $basePath parameter to service setup method in config.neon
- VasaB
- Member | 8
Hi all,
maybe I miss something, but currently I'm a little bit stuck on implementing texy filter, which will correctly handle urls to images.
My texy source file contains: [* something.jpg *]
What I want to achieve as result is correct path to image in form
/$basePath/images/something.jpg
. The $basePath
parameter is the part, I'm not sure how to make.
I register Texy as a service in my config.neon:
texyFilter:
class: App\Filters\TexyFilter
setup:
- createTexy(%imagesDir%, /* $basePath should go here */)
nette.latteFactory:
setup:
- addFilter('texy', [@texyFilter, process])
So my question is how can I pass $basePath
parameter to setup
method. Or if it's not possible I'd like to know, how you handle generating
correct image paths via Texy.
Thanks a lot for any answer.
- David Matějka
- Moderator | 6445
Hi, you can inject Nette\Http\IRequest and create base path from the url. See the template factory for the inspiration: https://api.nette.org/…ory.php.html#… :)
@Namespace %wwwDir%
is a system path to the www dir,
$basePath
is the base path in the url