ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 56 of file class.ilAppEventHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ilAppEventHandler::__construct ( )

Constructor.

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

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

Referenced by initListeners().

74  {
75  global $DIC;
76 
77  $this->db = $DIC->database();
78  $this->initListeners();
79 
80  $this->logger = \ilLoggerFactory::getLogger('evnt');
81  }
global $DIC
Definition: goto.php:24
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 83 of file class.ilAppEventHandler.php.

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

Referenced by __construct().

84  {
85  require_once('./Services/GlobalCache/classes/class.ilGlobalCache.php');
87  $cached_listeners = $ilGlobalCache->get('listeners');
88  if (is_array($cached_listeners)) {
89  $this->listener = $cached_listeners;
90 
91  return;
92  }
93 
94  $ilDB = $this->db;
95 
96  $this->listener = array();
97 
98  $sql = "SELECT * FROM il_event_handling" .
99  " WHERE type = " . $ilDB->quote("listen", "text");
100  $res = $ilDB->query($sql);
101  while ($row = $ilDB->fetchAssoc($res)) {
102  $this->listener[$row["id"]][] = $row["component"];
103  }
104 
105  $ilGlobalCache->set('listeners', $this->listener);
106  }
static getInstance($component)
foreach($_POST as $key=> $value) $res
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 61 of file class.ilAppEventHandler.php.

Referenced by initListeners().

◆ $listener

ilAppEventHandler::$listener
protected

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

Referenced by initListeners().

◆ $logger

ilAppEventHandler::$logger
protected

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


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