ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilAppEventHandler Class Reference

Global event handler. More...

+ Collaboration diagram for ilAppEventHandler:

Public Member Functions

 __construct ()
 Constructor. More...
 

Protected Member Functions

 initListeners ()
 

Protected Attributes

 $db
 
 $listener
 
 $logger
 

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
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilAppEventHandler::__construct ( )

Constructor.

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

References $DIC, ilLoggerFactory\getLogger(), and initListeners().

Referenced by initListeners().

76  {
77  global $DIC;
78 
79  $this->db = $DIC->database();
80  $this->initListeners();
81 
82  $this->logger = \ilLoggerFactory::getLogger('evnt');
83  }
global $DIC
Definition: saml.php:7
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ initListeners()

ilAppEventHandler::initListeners ( )
protected

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

References $db, $ilDB, $listener, $name, $res, $row, __construct(), ilGlobalCache\COMP_EVENTS, ilPluginAdmin\getActivePlugins(), ilPluginAdmin\getActivePluginsForSlot(), ilGlobalCache\getInstance(), and ilPluginAdmin\getPluginObject().

Referenced by __construct().

86  {
87  require_once('./Services/GlobalCache/classes/class.ilGlobalCache.php');
89  $cached_listeners = $ilGlobalCache->get('listeners');
90  if (is_array($cached_listeners)) {
91  $this->listener = $cached_listeners;
92 
93  return;
94  }
95 
96  $ilDB = $this->db;
97 
98  $this->listener = array();
99 
100  $sql = "SELECT * FROM il_event_handling" .
101  " WHERE type = " . $ilDB->quote("listen", "text");
102  $res = $ilDB->query($sql);
103  while ($row = $ilDB->fetchAssoc($res)) {
104  $this->listener[$row["id"]][] = $row["component"];
105  }
106 
107  $ilGlobalCache->set('listeners', $this->listener);
108  }
static getInstance($component)
foreach($_POST as $key=> $value) $res
$row
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilAppEventHandler::$db
protected

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

Referenced by initListeners().

◆ $listener

ilAppEventHandler::$listener
protected

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

Referenced by initListeners().

◆ $logger

ilAppEventHandler::$logger
protected

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


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