Inject Request int Service
- iwory
- Member | 147
Hello,
I would like to get instance of Nette\Application\Request
to my
own service.
But I don't know how can I inject it because everytime I get error
message Parameter $name in Nette\Application\Request::__construct() has no class type hint or default value, so its value must be specified
Is there some way how to?
Thank you
- David Matějka
- Moderator | 6445
Application request is not a service (there may be multiple app requests in a
single http request), but you can inject
Nette\Application\Application
and get a current request
from there
- David Matějka
- Moderator | 6445
I need it because I have service for prepare parameters and don't want to write it in presenter :)
well then may be better to follow @CZechBoY recommendation and pass the current Request object to the method you probably call from a presenter
- iwory
- Member | 147
David Matějka wrote:
I need it because I have service for prepare parameters and don't want to write it in presenter :)
well then may be better to follow @CZechBoY recommendation and pass the current Request object to the method you probably call from a presenter
Ok, I will follow recommendation from @CZechBoY and pass it from a presenter.