API16:JDispatcher/register
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Registers an event handler to the event dispatcher
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
register($event, $handler)
| Parameter Name | Default Value | Description |
|---|---|---|
| $event | $event Name of the event to register handler for | |
| $handler | $handler Name of the event handler |
Returns
void
Defined in
libraries/joomla/event/dispatcher.php
Importing
jimport( 'joomla.event.dispatcher' );
Source Body
public function register($event, $handler) { // Are we dealing with a class or function type handler? if (function_exists($handler)) { // Ok, function type event handler... lets attach it. $method = array('event' => $event, 'handler' => $handler); $this->attach($method); } elseif (class_exists($handler)) { // Ok, class type event handler... lets instantiate and attach it. $this->attach(new $handler($this)); } else { JError::raiseWarning('SOME_ERROR_CODE', 'JDispatcher::register: Event handler not recognized.', 'Handler: '.$handler); } }
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />
