I'm trying to create a base ViewModel called Base_ViewModel that other viewmodels inherit from.
I've created a folder in app ->classes -> view called "base" and created a file called viewmodel.php with the class declaration being the following inside the "base" folder:
class Base_ViewModel extends ViewModel{
public function view(){
$this->header = View::forge("header");
$this->footer = View::forge("footer");
}
}
Unfortunately, other viewmodels inheriting from this Base_ViewModel get an exception:
ErrorException [ Error ]: Class 'Base_ViewModel' not found
Are the autoloader rules different for this scenario?
No. The autoloader uses the 'classes' folder as the root of the cascading file system.
So classes\view\base\viewmodel.php would contain a class called View_Base_Viewmodel. Or a class Base_Viewmodel in the namespace "\View". Or a class called "Viewmodel" in the namespace "\View\Base".
Viewmodel classes are loaded from this folder because Viewmodel::forge() prefixes "View_" to the determined classname.