Joomla Library MVC Classes
Joomla provides several Controller, View and Model library classes, and this section gives an overview of these, and explains when your own component should use each class. However, it doesn't attempt to provide a full description of each class's functionality. The classes can be found in libraries/src/MVC.
Base MVC Classes
In practical terms, the lowest level classes you would be likely to use are:
- BaseController in libraries/src/MVC/Controller/BaseController.php
- HtmlView in libraries/src/MVC/View/HtmlView.php (for displaying web pages)
- BaseDatabaseModel in libraries/src/MVC/Model/BaseDatabaseModel.php
(If your component is responding to an Ajax call with a JSON-encoded object then you would use libraries/src/MVC/View/JsonView.php instead.)
In general, using these base classes is a good option if your component is displaying a single item on a site page.
BaseController
The functionality within BaseController includes:
- the
execute()
method described above, which runs the appropriate Controller function, based on the task parameter's<method>
part (which is passed to it). - functions for determining the appropriate View and Model classes to use (based on the setting of the view parameter within the HTTP request), and getting the MVCFactory class to create them
- a default
display()
method, which gets instances of the View and Model classes (including providing the View instance with a link to the Model instance), and then calls thedisplay()
method of the View class.