ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\ResourceStorage\Events\Subject Class Reference
+ Collaboration diagram for ILIAS\ResourceStorage\Events\Subject:

Public Member Functions

 __construct ()
 
 attach (Observer $observer, Event $event)
 
 detach (Observer $observer, Event $event=Event::ALL)
 

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

Definition at line 27 of file Subject.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\ResourceStorage\Events\Subject::__construct ( )

Definition at line 34 of file Subject.php.

35 {
36 $this->initObserverGroup((Event::ALL)->value);
37 }
@ ALL
event string being used if

References ALL, and ILIAS\ResourceStorage\Events\Subject\initObserverGroup().

+ Here is the call graph for this function:

Member Function Documentation

◆ attach()

ILIAS\ResourceStorage\Events\Subject::attach ( Observer  $observer,
Event  $event 
)

Definition at line 39 of file Subject.php.

39 : void
40 {
41 $this->initObserverGroup($event->value);
42
43 $this->observer_groups[$event->value][] = $observer;
44 }

References ILIAS\ResourceStorage\Events\Subject\initObserverGroup().

+ Here is the call graph for this function:

◆ detach()

ILIAS\ResourceStorage\Events\Subject::detach ( Observer  $observer,
Event  $event = Event::ALL 
)

Definition at line 46 of file Subject.php.

46 : void
47 {
48 $this->initObserverGroup($event->value);
49
50 foreach ($this->observer_groups[$event->value] as $index => $attached_observer) {
51 if ($attached_observer->getId() === $observer->getId()) {
52 unset($this->observer_groups[$event->value][$index]);
53 }
54 }
55 }
getId()
Unique identifier of the implementing event-listener.

References ILIAS\ResourceStorage\Events\Observer\getId(), and ILIAS\ResourceStorage\Events\Subject\initObserverGroup().

+ Here is the call graph for this function:

◆ initObserverGroup()

ILIAS\ResourceStorage\Events\Subject::initObserverGroup ( string  $group)
protected

Definition at line 82 of file Subject.php.

82 : void
83 {
84 if (!isset($this->observer_groups[$group])) {
85 $this->observer_groups[$group] = [];
86 }
87 }

Referenced by ILIAS\ResourceStorage\Events\Subject\__construct(), ILIAS\ResourceStorage\Events\Subject\attach(), and ILIAS\ResourceStorage\Events\Subject\detach().

+ Here is the caller graph for this function:

Field Documentation

◆ $observer_groups

array ILIAS\ResourceStorage\Events\Subject::$observer_groups = []
protected

Definition at line 32 of file Subject.php.


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