Global event handler. More...
Public Member Functions | |
| __construct () | |
| Constructor. | |
| raise ($a_component, $a_event, $a_parameter="") | |
| Raise an event. | |
Global event handler.
The event handler delegates application events (not gui events) between components that trigger events and components that listen to events. A component is a module or a service.
The component that triggers an event calls the raise function of the event handler through the global instance ilAppEventHandler:
E.g. in ilObjUser->delete(): $ilAppEventHandler->raise("Services/User", "deleteUser", array("id" => ..., ...))
A listener has to subscribe to the events of another component. This currently is done here in the constructor, e.g. if the News service listens to the User service, add a $this->listener["Services/User"] = array("Services/News"); This information will go to xml files in the future.
A component has to implement a listener class that implements Services/EventHandling/interfaces/interface.ilAppEventListener.php
The location must be <component>/classes/class.il<comp_name>AppEventListener.php, e.g. ./Services/News/classes/class.ilNewsAppEventListener.php
The class name must be il<comp_name>AppEventListener.
Definition at line 55 of file class.ilAppEventHandler.php.
| ilAppEventHandler::__construct | ( | ) |
Constructor.
Definition at line 60 of file class.ilAppEventHandler.php.
{
// this information should be determined by service/module
// xml files in the future
$this->listener["Services/News"] = array("Modules/Forum");
}
| ilAppEventHandler::raise | ( | $ | a_component, | |
| $ | a_event, | |||
| $ | a_parameter = "" | |||
| ) |
Raise an event.
The event is passed to all interested listeners.
| string | $a_component component, e.g. "Modules/Forum" or "Services/User" | |
| string | $a_event event e.g. "createUser", "updateUser", "deleteUser", ... | |
| array | $a_parameter parameter array (assoc), array("name" => ..., "phone_office" => ...) |
Definition at line 75 of file class.ilAppEventHandler.php.
References $file.
{
if (is_array($this->listener[$a_component]))
{
foreach ($this->listener[$a_component] as $listener)
{
// detemine class and file
$comp = explode("/", $listener);
$class = "il".$comp[1]."AppEventListener";
$file = "./".$listener."/classes/class.".$class.".php";
// if file exists, call listener
if (is_file($file))
{
include_once($file);
call_user_func(array($class, 'handleEvent'), $a_component, $a_event, $a_parameter);
}
}
}
}
1.7.1