Back to EventAware class

Method registerEvent

public $this
registerEvent
(mixed $event, callable $handler)
Registers a handler to a particular event group.
Parameters
  • string $event The event name.
  • callable $handler The handler, a function or an instance of an event object.
Returns
  • $this
Since
  • 4.0.0
Class: EventAware
Project: Joomla

Method registerEvent - Source code

/**
 * Registers a handler to a particular event group.
 *
 * @param   string    $event    The event name.
 * @param   callable  $handler  The handler, a function or an instance of an event object.
 *
 * @return  $this
 *
 * @since   4.0.0
 */
public function registerEvent($event, callable $handler)
{
    try {
        $this->getDispatcher()->addListener($event, $handler);
    } catch (\UnexpectedValueException $e) {
        // No dispatcher is registered, don't throw an error (mimics old behavior)
    }
    return $this;
}