EventEmittingService
class EventEmittingService (View source)
Main entry point for generating events
- TODO: explain Nested events
Properties
protected Event | $lastGeneratedEvent | a reference to the last-generated event |
|
protected Event[] | $eventContext | This array implements a stack of events. The last element of this stack is the current "parent event". |
|
protected string | $currentUsername | ||
protected EventRepository | $eventRepository | ||
protected UserService | $userDomainService | ||
protected bool | $enabled |
Methods
No description
Convenience method for generating an event and directly adding it afterwards to persistence.
Generates a new event, without persisting it yet.
Push the last-generated event onto the context, nesting all further generated events underneath the top-level one.
Remove an element from the context stack. Is the reverse operation to pushContext().
The current context-event or NULL if none exists currently.
Try to set the current username emitting the events, if possible
Details
bool
isEnabled()
No description
Event
emit(string $eventType, array $data, string $eventClassName = Event::class)
Convenience method for generating an event and directly adding it afterwards to persistence.
Event
generate(string $eventType, array $data, string $eventClassName = Event::class)
Generates a new event, without persisting it yet.
Note: Make sure to call add($event) afterwards.
void
add(Event $nodeEvent)
Add the passed event (which has been generated by generate()) to persistence.
This only happens for top-level-events. All events which are attached to some parent event are persisted together with the parent.
void
pushContext()
Push the last-generated event onto the context, nesting all further generated events underneath the top-level one.
void
popContext()
Remove an element from the context stack. Is the reverse operation to pushContext().
protected Event|null
getCurrentContext()
The current context-event or NULL if none exists currently.
protected void
initializeCurrentUsername()
Try to set the current username emitting the events, if possible