ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSessionAppEventListener Class Reference
+ Inheritance diagram for ilSessionAppEventListener:
+ Collaboration diagram for ilSessionAppEventListener:

Public Member Functions

 __construct (\ilDBInterface $db, \ilObjectDataCache $objectDataCache, \ilLogger $logger)
 
 withComponent ($component)
 
 withEvent ($event)
 
 withParameters (array $parameters)
 
 handle ()
 

Static Public Member Functions

static handleEvent ($a_component, $a_event, $a_parameter)
 Handle an event in a listener. More...
 

Private Member Functions

 handleRegisterEvent ()
 
 handleEnteredEvent ()
 
 handleUnregisterEvent ()
 
 fetchRecipientParticipants ()
 
 sendMail ($type)
 

Private Attributes

 $database
 
 $objectDataCache
 
 $logger
 
 $component
 
 $event
 
 $parameters
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilSessionAppEventListener::__construct ( \ilDBInterface  $db,
\ilObjectDataCache  $objectDataCache,
\ilLogger  $logger 
)
Parameters
ilDBInterface$db
ilObjectDataCache$objectDataCache
ilLogger$logger

Definition at line 44 of file class.ilSessionAppEventListener.php.

References $logger, and $objectDataCache.

48  {
49  $this->database = $db;
50  $this->objectDataCache = $objectDataCache;
51  $this->logger = $logger;
52  }

Member Function Documentation

◆ fetchRecipientParticipants()

ilSessionAppEventListener::fetchRecipientParticipants ( )
private

Definition at line 157 of file class.ilSessionAppEventListener.php.

Referenced by sendMail().

158  {
159  $object = new ilEventParticipants($this->parameters['obj_id']);
160 
161  $recipients = array();
162  $participants = $object->getParticipants();
163  foreach ($participants as $id => $participant) {
164  if ($participant['notification_enabled'] === true) {
165  $recipients[] = $id;
166  }
167  }
168 
169  return $recipients;
170  }
+ Here is the caller graph for this function:

◆ handle()

ilSessionAppEventListener::handle ( )

Definition at line 117 of file class.ilSessionAppEventListener.php.

References Vendor\Package\$e, handleEnteredEvent(), handleRegisterEvent(), and handleUnregisterEvent().

118  {
119  if ('Modules/Session' !== $this->component) {
120  return;
121  }
122 
123  try {
124  if ('register' === $this->event) {
125  $this->handleRegisterEvent();
126  } elseif ('enter' === $this->event) {
127  $this->handleEnteredEvent();
128  } elseif ('unregister' === $this->event) {
129  $this->handleUnregisterEvent();
130  }
131  } catch (\ilException $e) {
132  $this->logger->error($e->getMessage());
133  }
134  }
+ Here is the call graph for this function:

◆ handleEnteredEvent()

ilSessionAppEventListener::handleEnteredEvent ( )
private

Definition at line 143 of file class.ilSessionAppEventListener.php.

References $type, sendMail(), and ilSessionMembershipMailNotification\TYPE_ENTER_NOTIFICATION.

Referenced by handle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleEvent()

static ilSessionAppEventListener::handleEvent (   $a_component,
  $a_event,
  $a_parameter 
)
static

Handle an event in a listener.

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" => ...)

Implements ilAppEventListener.

Definition at line 100 of file class.ilSessionAppEventListener.php.

References $DIC.

101  {
102  global $DIC;
103 
104  $listener = new static(
105  $DIC->database(),
106  $DIC['ilObjDataCache'],
107  $DIC->logger()->sess()
108  );
109 
110  $listener
111  ->withComponent($a_component)
112  ->withEvent($a_event)
113  ->withParameters($a_parameter)
114  ->handle();
115  }
$DIC
Definition: xapitoken.php:46

◆ handleRegisterEvent()

ilSessionAppEventListener::handleRegisterEvent ( )
private

Definition at line 136 of file class.ilSessionAppEventListener.php.

References $type, sendMail(), and ilSessionMembershipMailNotification\TYPE_REGISTER_NOTIFICATION.

Referenced by handle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleUnregisterEvent()

ilSessionAppEventListener::handleUnregisterEvent ( )
private

Definition at line 150 of file class.ilSessionAppEventListener.php.

References $type, sendMail(), and ilSessionMembershipMailNotification\TYPE_UNREGISTER_NOTIFICATION.

Referenced by handle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMail()

ilSessionAppEventListener::sendMail (   $type)
private
Parameters
array$recipients
$type
Exceptions
ilException

Definition at line 177 of file class.ilSessionAppEventListener.php.

References $type, and fetchRecipientParticipants().

Referenced by handleEnteredEvent(), handleRegisterEvent(), and handleUnregisterEvent().

178  {
179  $recipients = $this->fetchRecipientParticipants();
180  if (array() !== $recipients) {
181  $notification = new ilSessionMembershipMailNotification();
182  $notification->setRecipients($recipients);
183  $notification->setType($type);
184  $notification->setRefId($this->parameters['ref_id']);
185 
186  $notification->send($this->parameters['usr_id']);
187  }
188  }
$type
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withComponent()

ilSessionAppEventListener::withComponent (   $component)
Parameters
string$component
Returns

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

References $component.

59  {
60  $clone = clone $this;
61 
62  $clone->component = $component;
63 
64  return $clone;
65  }

◆ withEvent()

ilSessionAppEventListener::withEvent (   $event)
Parameters
string$event
Returns

Definition at line 71 of file class.ilSessionAppEventListener.php.

References $event.

72  {
73  $clone = clone $this;
74 
75  $clone->event = $event;
76 
77  return $clone;
78  }

◆ withParameters()

ilSessionAppEventListener::withParameters ( array  $parameters)
Parameters
array$parameters
Returns

Definition at line 84 of file class.ilSessionAppEventListener.php.

References $parameters.

85  {
86  $clone = clone $this;
87 
88  $clone->parameters = $parameters;
89 
90  return $clone;
91  }

Field Documentation

◆ $component

ilSessionAppEventListener::$component
private

Definition at line 27 of file class.ilSessionAppEventListener.php.

Referenced by withComponent().

◆ $database

ilSessionAppEventListener::$database
private

Definition at line 12 of file class.ilSessionAppEventListener.php.

◆ $event

ilSessionAppEventListener::$event
private

Definition at line 32 of file class.ilSessionAppEventListener.php.

Referenced by withEvent().

◆ $logger

ilSessionAppEventListener::$logger
private

Definition at line 22 of file class.ilSessionAppEventListener.php.

Referenced by __construct().

◆ $objectDataCache

ilSessionAppEventListener::$objectDataCache
private

Definition at line 17 of file class.ilSessionAppEventListener.php.

Referenced by __construct().

◆ $parameters

ilSessionAppEventListener::$parameters
private

Definition at line 37 of file class.ilSessionAppEventListener.php.

Referenced by withParameters().


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