Exemplo n.º 1
0
 public function testGuard()
 {
     $subject = new GenericSubject('test_machine', 'state1');
     $guard = new VariableGuard(['expression' => 'event === "erp.derped"']);
     $subject->getExecutionContext()->setParameter('event', 'erp.derped');
     $this->assertTrue($guard->accept($subject));
     $this->assertEquals(PHP_EOL . 'if event === "erp.derped"', $guard->__toString());
 }
Exemplo n.º 2
0
 public function accept(StatefulSubjectInterface $process_state)
 {
     if ($this->hasOption('expression') && !parent::accept($process_state)) {
         return false;
     }
     $export_val = null;
     $export_key = $this->options->get('export_to', false);
     $execution_context = $process_state->getExecutionContext();
     $projection = $this->findProjection($this->getPayloadIdentifier($process_state));
     if ($projection) {
         $export_val = $projection;
         if ($this->options->has('export_as_reference')) {
             $export_config = $this->options->get('export_as_reference');
             $embed_type = $export_config->get('reference_embed_type');
             $execution_context->setParameter($export_config->get('export_to'), [['@type' => $embed_type, 'referenced_identifier' => $projection->getIdentifier()]]);
         }
     }
     if ($export_key) {
         $execution_context->setParameter($export_key, $export_val);
     }
     return $projection != null;
 }