Back to CMSPlugin class

Method registerListener

protected void
registerListener
(string $methodName)
Registers a proper event listener, i.e. a method which accepts an AbstractEvent as its sole argument. This is the preferred way to implement plugins in Joomla! 4.x and will be the only possible method with Joomla! 5.x onwards.
Parameters
  • string $methodName The method name to register
Returns
  • void
Since
  • 4.0.0
Class: CMSPlugin
Project: Joomla

Method registerListener - Source code

/**
 * Registers a proper event listener, i.e. a method which accepts an AbstractEvent as its sole argument. This is the
 * preferred way to implement plugins in Joomla! 4.x and will be the only possible method with Joomla! 5.x onwards.
 *
 * @param   string  $methodName  The method name to register
 *
 * @return  void
 *
 * @since   4.0.0
 */
protected final function registerListener(string $methodName)
{
    $this->getDispatcher()->addListener($methodName, [$this, $methodName]);
}