- Member | 625
so i wanted to modify the method Application::processRequest to pass httpRequest and httResponse to the Application::onResponse event.
well i failed hard because these 6 properties are private
<?php /** @var Request */ private $requests = array(); /** @var IPresenter */ private $presenter; /** @var Nette\Http\IRequest */ private $httpRequest; /** @var Nette\Http\IResponse */ private $httpResponse; /** @var IPresenterFactory */ private $presenterFactory; /** @var IRouter */ private $router; ?>
so to make a slight change in app behaviour i have to basically copy all the
code from the parent class.
which is bollocks.
since you can replace the Application class with one line in config.neon i think it should be more extensible and thus propose these 6 properties to have their accessibility changed to protected.
- Member | 100
For your original intention, passing Http\Request and Http\Response to Application::onResponse, you can always pass a method callback and inject those into the method's class..
Or, you know, you can override Application's constructor to get access to 4 of those 6 things. And for Requests array, you have onRequest event. And I don't think Presenter should be protected.. EDIT: Oh right but then you would have to also copy all the bollocks. That's true.
What I'm trying to say is maybe you might need to rethink whatever it is you are trying to do. Modifying internal classes is generally not a good idea (although in some cases it can be justifiable), and usually Nette offers enough instruments to avoid it.
Last edited by looky (2014-11-09 00:55)
- Member | 625
That's not the point here. The point is if I want to change anything in this class, e.g. add another event for example I have to copy all the code instead of overriding one method, which makes no sense.
As for your proposal: that's just unnecessarily complicated and adds overhead. When I could just add one line to index.php
Either way, I created my application, got access to http request and did what I wanted but it was pointless because response handling is done in a very weird way. But that's another issue.
But still, I think my original point holds. It affects in no way any existing code, it just makes developers' life easier