Example #1
0
 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;
 }
Example #2
0
 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;
 }
Example #3
0
 public function testCallChainInvalid()
 {
     $category = new Category('programming', []);
     $title = Maybe::unit($category)->getFirstArticle()->getTitle();
     $this->assertInstanceOf(None::CLASS, $title);
 }