public function onExit(StatefulSubjectInterface $process_state) { parent::onExit($process_state); $this->requiresVariable('incoming_event', $process_state); $execution_context = $process_state->getExecutionContext(); $export_as_reference = $this->options->get('export_as_reference', false); if ($export_as_reference) { $event = $execution_context->getParameter('incoming_event'); $export_key = $export_as_reference->get('export_to'); $reference_data = [['@type' => $export_as_reference->get('reference_embed_type'), 'referenced_identifier' => $event->getAggregateRootIdentifier()]]; $execution_context->setParameter($export_key, $reference_data); } }
public function onExit(StatefulSubjectInterface $process_state) { parent::onExit($process_state); $execution_context = $process_state->getExecutionContext(); $incoming_event = $execution_context->getParameter('incoming_event'); if ($incoming_event instanceof NoOpSignal) { $command_data = $incoming_event->getCommandData(); $aggregate_root_identifier = $command_data['aggregate_root_identifier']; } else { $aggregate_root_identifier = $incoming_event->getAggregateRootIdentifier(); } $export_key = null; if ($this->options->has('export_as_reference')) { $export_as_reference = $this->options->get('export_as_reference'); $embed_type = $export_as_reference->get('reference_embed_type'); $export_key = $export_as_reference->get('export_to'); $reference_data = [['@type' => $embed_type, 'referenced_identifier' => $aggregate_root_identifier]]; $execution_context->setParameter($export_key, $reference_data); } $projection_key = $this->options->get('projection_key'); if ($projection_key !== $export_key) { $execution_context->removeParameter($projection_key); } }