ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCtrlSubject Class Reference
+ Collaboration diagram for ilCtrlSubject:

Public Member Functions

 __construct ()
 
 attach (ilCtrlObserver $observer, ilCtrlEvent $event)
 
 detach (ilCtrlObserver $observer, ilCtrlEvent $event=ilCtrlEvent::ALL)
 
 notify (ilCtrlEvent $event, ?string $data)
 

Protected Member Functions

 initObserverGroup (string $group)
 

Protected Attributes

array $observer_groups = []
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s
Thibeau Fuhrer thibe.nosp@m.au@s.nosp@m.r.sol.nosp@m.utio.nosp@m.ns AutoloadingIssuesInspection

Definition at line 26 of file class.ilCtrlSubject.php.

Constructor & Destructor Documentation

◆ __construct()

ilCtrlSubject::__construct ( )

Definition at line 33 of file class.ilCtrlSubject.php.

References ALL, and initObserverGroup().

34  {
35  $this->initObserverGroup((ilCtrlEvent::ALL)->value);
36  }
initObserverGroup(string $group)
event string being used if
+ Here is the call graph for this function:

Member Function Documentation

◆ attach()

ilCtrlSubject::attach ( ilCtrlObserver  $observer,
ilCtrlEvent  $event 
)

Definition at line 38 of file class.ilCtrlSubject.php.

References initObserverGroup().

38  : void
39  {
40  $this->initObserverGroup($event->value);
41 
42  $this->observer_groups[$event->value][] = $observer;
43  }
initObserverGroup(string $group)
+ Here is the call graph for this function:

◆ detach()

ilCtrlSubject::detach ( ilCtrlObserver  $observer,
ilCtrlEvent  $event = ilCtrlEvent::ALL 
)

Definition at line 45 of file class.ilCtrlSubject.php.

References ilCtrlObserver\getId(), and initObserverGroup().

45  : void
46  {
47  $this->initObserverGroup($event->value);
48 
49  foreach ($this->observer_groups[$event->value] as $index => $attached_observer) {
50  if ($attached_observer->getId() === $observer->getId()) {
51  unset($this->observer_groups[$event->value][$index]);
52  }
53  }
54  }
initObserverGroup(string $group)
getId()
Unique identifier of the implementing event-listener.
+ Here is the call graph for this function:

◆ initObserverGroup()

ilCtrlSubject::initObserverGroup ( string  $group)
protected

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

Referenced by __construct(), attach(), detach(), and notify().

70  : void
71  {
72  if (!isset($this->observer_groups[$group])) {
73  $this->observer_groups[$group] = [];
74  }
75  }
+ Here is the caller graph for this function:

◆ notify()

ilCtrlSubject::notify ( ilCtrlEvent  $event,
?string  $data 
)

Definition at line 56 of file class.ilCtrlSubject.php.

References ALL, and initObserverGroup().

56  : void
57  {
58  $this->initObserverGroup($event->value);
59 
60  $observers = array_merge(
61  $this->observer_groups[(ilCtrlEvent::ALL)->value],
62  $this->observer_groups[$event->value],
63  );
64 
65  foreach ($observers as $interessted_observer) {
66  $interessted_observer->update($event, $data);
67  }
68  }
initObserverGroup(string $group)
event string being used if
+ Here is the call graph for this function:

Field Documentation

◆ $observer_groups

array ilCtrlSubject::$observer_groups = []
protected

Definition at line 31 of file class.ilCtrlSubject.php.


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