Closed ronan-gloo closed 12 years ago
This is how PHP works.
Your abstract class does not exist as such, the code is executed in the context of \Admin\Controller_Home, and therefore the viewmodel should be \Admin\View_Application.
Your suggestion goes horribly wrong if a class by that name exists in the global namespace, but has nothing to do with what you're requesting. Which is how FuelPHP applications work.
Yes, i know how it's supposed to work, but there is still a problem: If a class 'Application' exists in the global namespace, ViewModel class will load it, wich is, to my opinion, an unexpected behavior, cause view model names are supposed to be prefixed by a 'View_' and located in the 'view' folder according framework's conventions.
It's intended behavior to first look for "View_{viewmodelname}", and if not found for "{viewmodelname}" in the required namespace. If this behaviour is not clear (enough) the docs have to be amended.
It is up to you as developer to make sure whatever is supposed to be loaded actually exists.
According https://github.com/fuel/core/blob/1.4/develop/classes/viewmodel.php#L33, ViewModel class is autodetected from the active request namespace, or fallback on raw $viewmodel name if class is not found. (basically, first arg without it's extension)
But in this scenario, ViewModel class is not found: https://gist.github.com/3867967. The method is looking for \Admin\View_Application or \application, but not for \View_Application.
Something like this could be fix it: https://gist.github.com/3868001