Created
December 14, 2020 16:22
-
-
Save Miljar/8895c18b1ca014bbbcad1ccb6c149d56 to your computer and use it in GitHub Desktop.
Prooph Projection state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DocumentReceiverWasRemoved::class => function ($state, DocumentReceiverWasRemoved $event) { | |
/** @var ReadModel $readModel */ | |
$readModel = $this->readModel(); | |
$receivers = array_filter( | |
$state[self::DOCUMENTS_KEY][$event->documentId()->toString()][self::DOCUMENT_RECEIVERS_KEY], | |
function ($receiver) use ($event) { | |
return $receiver['id'] !== $event->receiver()->value(); | |
} | |
); | |
$state[self::DOCUMENTS_KEY][$event->documentId()->toString()][self::DOCUMENT_RECEIVERS_KEY] = $receivers; | |
// persist to Elastic Search | |
$readModel->stack( | |
'removeDocumentReceiver', | |
$event->documentId()->toString(), | |
$event->receiver()->value() | |
); | |
$readModel->persist(); | |
return $state; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment