This content may be out-of-date

This book was written circa 2022, when Joomla 4 was still a new thing. It has not been updated for Joomla 5 and beyond, and it's no longer being worked on. You can usually find more up-to-date information in the official Joomla! Manual.

Getting the Dispatcher

The extension object is responsible for returning a number of interesting objects through its methods. These objects are meant to be used for interacting with the component. One of these is getDispatcher which lets us retrieve the component's Dispatcher object.

Your extension can have a custom dispatcher class, \My\Component\Example\Dispatcher\Dispatcher, where \My\Component\Example is your component's prefix. If this class exists, an object instance of it is returned.

If your extension does not have a dispatcher an instance of the default Joomla\CMS\Dispatcher\ComponentDispatcher (site and administrator applications) or Joomla\CMS\Dispatcher\ApiDispatcher (API application) will be created and returned instead.