Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Improving JController::getInstance method #990
I came across this pull request:
...and think it makes a lot of sense. Why was this closed exactly?
Also, why does the format variable get appended to the filename of the controller? For example, if format=raw and the controller is called MyController then it would look for mycontroller.raw.php. While this convention might make sense for views, I don't see how it's helpful for controllers...why would you want an entirely separate controller class just because you want one method that outputs JSON instead of HTML? And frequently you might want a method to be able to display either format.
At the very least it seems important to allow the user to specify the a format setting (which might be different from JRequest::getVar('format')) in the config array.
Also, I think the inclusion of $format on line 267 might be a bug:
throw new JException(JText::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER', $type, $format), 1056, E_ERROR, $type, true);
It seems to me this should be a format string to be passed to sprintf, if anything, not the format variable from the request.
I can split these into separate issues if that would be more helpful but they seemed so closely related that I thought it made sense to put them all in the same issue.