PHP Class Neos\Neos\EventLog\Domain\Service\EventEmittingService

- TODO: explain Nested events
Show file Open project: neos/neos-development-collection Class Usage Examples

Protected Properties

Property Type Description
$currentAccountIdentifier string
$enabled boolean
$eventContext array If the stack is empty, the events are created top-level.
$eventRepository Neos\Neos\EventLog\Domain\Repository\EventRepository
$lastGeneratedEvent Neos\Neos\EventLog\Domain\Model\Event a reference to the last-generated event

Public Methods

Method Description
add ( Event $nodeEvent ) : void Add the passed event (which has been generated by generate()) to persistence.
emit ( string $eventType, array $data, string $eventClassName = Event::class ) : Event Convenience method for generating an event and directly adding it afterwards to persistence.
generate ( string $eventType, array $data, string $eventClassName = Event::class ) : Event Generates a new event, without persisting it yet.
isEnabled ( ) : boolean
popContext ( ) : void Remove an element from the context stack. Is the reverse operation to pushContext().
pushContext ( ) : void Push the last-generated event onto the context, nesting all further generated events underneath the top-level one.
setCurrentAccountIdentifier ( string $accountIdentifier ) : void Set the current account identifier

Protected Methods

Method Description
getCurrentContext ( ) : Event | null The current context-event or NULL if none exists currently.

Method Details

add() public method

This only happens for top-level-events. All events which are attached to some parent event are persisted together with the parent.
See also: emit()
public add ( Event $nodeEvent ) : void
$nodeEvent Neos\Neos\EventLog\Domain\Model\Event
return void

emit() public method

Convenience method for generating an event and directly adding it afterwards to persistence.
public emit ( string $eventType, array $data, string $eventClassName = Event::class ) : Event
$eventType string
$data array
$eventClassName string
return Neos\Neos\EventLog\Domain\Model\Event

generate() public method

Note: Make sure to call add($event) afterwards.
See also: emit()
public generate ( string $eventType, array $data, string $eventClassName = Event::class ) : Event
$eventType string
$data array
$eventClassName string
return Neos\Neos\EventLog\Domain\Model\Event

getCurrentContext() protected method

The current context-event or NULL if none exists currently.
protected getCurrentContext ( ) : Event | null
return Neos\Neos\EventLog\Domain\Model\Event | null

isEnabled() public method

public isEnabled ( ) : boolean
return boolean TRUE if the event log is enabled and events should be captured

popContext() public method

Remove an element from the context stack. Is the reverse operation to pushContext().
public popContext ( ) : void
return void

pushContext() public method

Push the last-generated event onto the context, nesting all further generated events underneath the top-level one.
public pushContext ( ) : void
return void

setCurrentAccountIdentifier() public method

Set the current account identifier
public setCurrentAccountIdentifier ( string $accountIdentifier ) : void
$accountIdentifier string
return void

Property Details

$currentAccountIdentifier protected property

protected string $currentAccountIdentifier
return string

$enabled protected property

protected bool $enabled
return boolean

$eventContext protected property

If the stack is empty, the events are created top-level.
protected array $eventContext
return array

$eventRepository protected property

protected EventRepository,Neos\Neos\EventLog\Domain\Repository $eventRepository
return Neos\Neos\EventLog\Domain\Repository\EventRepository

$lastGeneratedEvent protected property

a reference to the last-generated event
protected Event,Neos\Neos\EventLog\Domain\Model $lastGeneratedEvent
return Neos\Neos\EventLog\Domain\Model\Event