ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAppEventHandler Class Reference

Global event handler. More...

+ Collaboration diagram for ilAppEventHandler:

Public Member Functions

 __construct ()
 Constructor.
 raise ($a_component, $a_event, $a_parameter="")
 Raise an event.

Protected Member Functions

 initListeners ()

Protected Attributes

 $listener

Detailed Description

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.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 55 of file class.ilAppEventHandler.php.

Constructor & Destructor Documentation

ilAppEventHandler::__construct ( )

Constructor.

Definition at line 62 of file class.ilAppEventHandler.php.

References initListeners().

{
/* moved to respective module.xml/service.xml
$this->listener["Services/News"] = array("Modules/Forum");
$this->listener['Modules/Group'] = array('Services/Calendar');
$this->listener['Modules/Session'] = array('Services/Calendar');
$this->listener['Modules/Course'] = array('Services/Calendar',
'Services/WebServices/ECS','Services/ContainerReference');
$this->listener['Modules/Category'] = array('Services/ContainerReference');
$this->listener['Modules/RemoteCourse'] = array('Services/WebServices/ECS');
$this->listener["Services/Object"] = array("Services/Tagging",'Services/Search',
'Modules/MediaPool');
$this->listener['Services/Authentication'] = array();
$this->listener['Services/Tracking'] = array('Modules/Course');
*/
$this->initListeners();
}

+ Here is the call graph for this function:

Member Function Documentation

ilAppEventHandler::initListeners ( )
protected

Definition at line 81 of file class.ilAppEventHandler.php.

References $res, and $row.

Referenced by __construct().

{
global $ilDB;
$this->listener = array();
$sql = "SELECT * FROM il_event_handling".
" WHERE type = ".$ilDB->quote("listen", "text");
$res = $ilDB->query($sql);
while($row = $ilDB->fetchAssoc($res))
{
$this->listener[$row["id"]][] = $row["component"];
}
}

+ Here is the caller graph for this function:

ilAppEventHandler::raise (   $a_component,
  $a_event,
  $a_parameter = "" 
)

Raise an event.

The event is passed to all interested listeners.

Parameters
string$a_componentcomponent, e.g. "Modules/Forum" or "Services/User"
string$a_eventevent e.g. "createUser", "updateUser", "deleteUser", ...
array$a_parameterparameter array (assoc), array("name" => ..., "phone_office" => ...)

Definition at line 103 of file class.ilAppEventHandler.php.

References $file, $listener, ilPluginAdmin\getActivePluginsForSlot(), and ilPluginAdmin\getPluginObject().

{
if (is_array($this->listener[$a_component]))
{
foreach ($this->listener[$a_component] as $listener)
{
// Allow listeners like Services/WebServices/ECS
$last_slash = strripos($listener,'/');
$comp = substr($listener,0,$last_slash);
$class = 'il'.substr($listener,$last_slash + 1).'AppEventListener';
$file = "./".$listener."/classes/class.".$class.".php";
// 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);
}
}
}
// get all event hook plugins and forward the event to them
include_once("./Services/Component/classes/class.ilPluginAdmin.php");
$plugins = ilPluginAdmin::getActivePluginsForSlot("Services", "EventHandling", "evhk");
foreach ($plugins as $pl)
{
$plugin = ilPluginAdmin::getPluginObject("Services", "EventHandling",
"evhk", $pl);
$plugin->handleEvent($a_component, $a_event, $a_parameter);
}
}

+ Here is the call graph for this function:

Field Documentation

ilAppEventHandler::$listener
protected

Definition at line 57 of file class.ilAppEventHandler.php.

Referenced by raise().


The documentation for this class was generated from the following file: