RequestInterface - missing methods |
Hi,
this is from the documentation: "The User Agent class is always available directly from the current IncomingRequest instance." PHP Code: <?php $this->request->getUserAgent() and other methods are not available. Is this a bug in the documentation? The RequestInterface has no such methods.
IncomingRequest is not RequestInterface.
(06-22-2022, 02:25 PM)kenjis Wrote: IncomingRequest is not RequestInterface. I know, but this is the code in the documentation and it is not working for all cases. With this code i have no access to the userAgent and other methods. It is only working if i use the IncomingRequest $request, but this is different from the documentation. (06-22-2022, 02:33 PM)groovebird Wrote: I know, but this is the code in the documentation and it is not working for all cases. With this code i have no access to the userAgent and other methods. It is only working if i use the IncomingRequest $request, but this is different from the documentation. Where in the documentation? If it is in the documentation, it is a bug of the documentation.
(06-22-2022, 02:35 PM)kenjis Wrote: Where in the documentation? This is the first Link: https://codeigniter.com/user_guide/libra...-the-class "The User Agent class is always available directly from the current IncomingRequest instance." There is a link to this page: https://codeigniter.com/user_guide/incom...quest.html It’s preferable, though, to pass the request in as a dependency if the class is anything other than the controller, where you can save it as a class property: with the code i posted earlier: PHP Code: <?php Here the RequestInterface is used but there is no UserAgent object
Thanks.
Quote:It’s preferable, though, to pass the request in as a dependency if the class is anything other than the controller, where you can save it as a class property: This is correct, but RequestInterface is not IncomingRequest. You can use RequestInterface, but if you use it, you can't use some methods in IncomingRequest. It is better to fix the sample code. |
Welcome Guest, Not a member yet? Register Sign In |