Passing config paramater to all presenters
Notice: This thread is very old.
- Etruska
- Member | 25
Hi,
I would like to pass parameter(s) from configuration to <head> section in
layout so it probably has to be passed to all front-end presenters. I guess
I could make a service which only purpose would be to carry the parameter and
inject the service to BasePresenter. However I don't find such service very
useful and also I've read some bad things about using BasePresenter. What would
you recommend? Thank you for your advice.
- Tomáš Votruba
- Moderator | 1114
Hi, you could make a component {control head}.
Ad BasePresenter: I prefer using traits which I pass to presenter. E.g. TWebloaderComponents is more clear than BasePresenter.
- Tomáš Votruba
- Moderator | 1114
You can pass it directly to component.
services:
-
implement: IHeadComponent
setup:
- setParameters(@Nette\DI\Container::parameters)
It's called generated factories, see this article (in czech)