interface ProjectionInterface (View source)

Common interface for a Content Repository projection. This API is NOT exposed to the outside world, but is the contract between {ContentRepository} and the individual projections.

If the Projection needs to be notified that a catchup is about to happen, you can additionally implement {\Neos\ContentRepository\Core\Projection\WithMarkStaleInterface}. This is useful f.e. to disable runtime caches in the ProjectionState.

Methods

void
setUp()

Set up the projection state (create databases, call CheckpointStorage::setup()).

bool
canHandle(Event $event)

Can the projection handle this event? Must be deterministic.

void
catchUp(EventStreamInterface $eventStream, ContentRepository $contentRepository)

Catch up the projection, consuming the not-yet-seen events in the given event stream.

SequenceNumber
getSequenceNumber()

Part of the Blocking implementation of commands - usually delegates to an internal {CheckpointStorageInterface::getHighestAppliedSequenceNumber()}.

getState()

NOTE: The ProjectionStateInterface returned must be ALWAYS THE SAME INSTANCE.

void
reset()

No description

Details

void setUp()

Set up the projection state (create databases, call CheckpointStorage::setup()).

Return Value

void

bool canHandle(Event $event)

Can the projection handle this event? Must be deterministic.

Used to determine whether this projection should be triggered in response to an event; and also needed as part of the Blocking logic ({\Neos\ContentRepository\Core\CommandHandler\PendingProjections}).

Parameters

Event $event

Return Value

bool

void catchUp(EventStreamInterface $eventStream, ContentRepository $contentRepository)

Catch up the projection, consuming the not-yet-seen events in the given event stream.

How this is called depends a lot on your infrastructure - usually via some indirection from {\Neos\ContentRepository\Core\Projection\ProjectionCatchUpTriggerInterface}.

Parameters

EventStreamInterface $eventStream
ContentRepository $contentRepository

Return Value

void

SequenceNumber getSequenceNumber()

Part of the Blocking implementation of commands - usually delegates to an internal {CheckpointStorageInterface::getHighestAppliedSequenceNumber()}.

See {\Neos\ContentRepository\Core\CommandHandler\PendingProjections} for implementation details.

Return Value

SequenceNumber

ProjectionStateInterface getState()

NOTE: The ProjectionStateInterface returned must be ALWAYS THE SAME INSTANCE.

If the Projection needs to be notified that a catchup is about to happen, you can additionally implement {\Neos\ContentRepository\Core\Projection\WithMarkStaleInterface}. This is useful f.e. to disable runtime caches in the ProjectionState.

void reset()

No description

Return Value

void