public function handleEvent(EventInterface $event) { $metadata = Maybe::unit($event->getMetadata()); $process_uuid = $metadata->process_uuid->get(); $process_name = $metadata->process_name->get(); if ($process_uuid && $process_name) { $process_state = $this->process_manager->continueProcess($event); if ($this->process_manager->hasCompleted($process_state)) { $this->event_bus->distribute(ChannelMap::CHANNEL_INFRA, new ProcessCompletedEvent(['uuid' => Uuid::uuid4()->toString(), 'process_state' => $process_state])); } return $process_state; } return null; }
protected function loadProcessStateBy(EventInterface $event) { $metadata = Maybe::unit($event->getMetadata()); $process_uuid = $metadata->process_uuid->get(); $process_name = $metadata->process_name->get(); if ($process_uuid && $process_name) { $process_state = $this->readProcessState($process_uuid); if (!$process_state || $process_state->getProcessName() !== $process_name) { throw new RuntimeError(sprintf('Given process name "%s" coming from event metadata does not match the loaded one: "%s"', $process_name, $process_state->getProcessName())); } } else { $process_state = null; } return $process_state; }
public function testCallChainInvalid() { $category = new Category('programming', []); $title = Maybe::unit($category)->getFirstArticle()->getTitle(); $this->assertInstanceOf(None::CLASS, $title); }