ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilChatroomAppEventListener Class Reference
+ Inheritance diagram for ilChatroomAppEventListener:
+ Collaboration diagram for ilChatroomAppEventListener:

Static Public Member Functions

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

Private Member Functions

 __construct (ilDBInterface $database)
 
 handle (string $component, string $event, array $parameter)
 
 dbCachePrepare (ilDBInterface $db)
 
 cache (Closure $proc)
 @template A @template B More...
 

Private Attributes

readonly CleanUpBans $clean_up
 

Static Private Attributes

static ilChatroomAppEventListener $instance = null
 

Detailed Description

Definition at line 23 of file class.ilChatroomAppEventListener.php.

Constructor & Destructor Documentation

◆ __construct()

ilChatroomAppEventListener::__construct ( ilDBInterface  $database)
private

Definition at line 39 of file class.ilChatroomAppEventListener.php.

40 {
41 $this->clean_up = new CleanUpBans($this->dbCachePrepare($database));
42 }

References dbCachePrepare().

+ Here is the call graph for this function:

Member Function Documentation

◆ cache()

ilChatroomAppEventListener::cache ( Closure  $proc)
private

@template A @template B

Parameters
Closure(...A)B
Returns
Closure(...A): B

Definition at line 69 of file class.ilChatroomAppEventListener.php.

69 : Closure
70 {
71 $cache = [];
72 return function (...$args) use (&$cache, $proc) {
73 $key = json_encode($args);
74 if (!isset($cache[$key])) {
75 $cache[$key] = $proc(...$args);
76 }
77 return $cache[$key];
78 };
79 }

Referenced by dbCachePrepare().

+ Here is the caller graph for this function:

◆ dbCachePrepare()

ilChatroomAppEventListener::dbCachePrepare ( ilDBInterface  $db)
private
Returns
Closure(string, array): Closure(array): void

Definition at line 54 of file class.ilChatroomAppEventListener.php.

54 : Closure
55 {
56 return $this->cache(function (...$args) use ($db): Closure {
57 $statement = $db->prepare(...$args);
58 return fn(array $values = []) => $db->execute($statement, $values);
59 });
60 }
cache(Closure $proc)
@template A @template B
execute(ilDBStatement $stmt, array $data=[])
prepare(string $a_query, ?array $a_types=null, ?array $a_result_types=null)
Prepare a query (SELECT) statement to be used with execute.

References cache(), ilDBInterface\execute(), and ilDBInterface\prepare().

Referenced by __construct().

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

◆ handle()

ilChatroomAppEventListener::handle ( string  $component,
string  $event,
array  $parameter 
)
private

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

44 : void
45 {
46 if ($event === 'deleteUser') {
47 $this->clean_up->removeEntriesOfDeletedUser($parameter['usr_id']);
48 }
49 }

◆ handleEvent()

static ilChatroomAppEventListener::handleEvent ( string  $component,
string  $event,
array  $parameter 
)
static
Parameters
array<string,mixed>$a_parameter

Implements ilAppEventListener.

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

32 : void
33 {
34 global $DIC;
35 self::$instance ??= new self($DIC->database());
36 self::$instance->handle($component, $event, $parameter);
37 }
global $DIC
Definition: shib_login.php:26

References $DIC.

Field Documentation

◆ $clean_up

readonly CleanUpBans ilChatroomAppEventListener::$clean_up
private

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

◆ $instance

ilChatroomAppEventListener ilChatroomAppEventListener::$instance = null
staticprivate

Definition at line 25 of file class.ilChatroomAppEventListener.php.


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