Example #1
0
 /**
  * Propagates the new state machine position to the execution context of the given subject,
  * by calling the execution context's "onStateExit" method.
  *
  * @param StatefulSubjectInterface $subject
  */
 public function onExit(StatefulSubjectInterface $subject)
 {
     parent::onExit($subject);
     foreach ($this->getOption(self::OPTION_REMOVE_VARS, []) as $key) {
         $subject->getExecutionContext()->removeParameter($key);
     }
 }
 public function onEntry(StatefulSubjectInterface $process_state)
 {
     if (!$process_state instanceof ProcessStateInterface) {
         throw new RuntimeError('Only ' . ProcessStateInterface::CLASS . ' subjects supported by ' . static::CLASS);
     }
     parent::onEntry($process_state);
     $commands = $this->createCommands($process_state);
     $execution_context = $process_state->getExecutionContext();
     $execution_context->setParameter('commands', new CommandList($commands));
 }
Example #3
0
 public function testConstructorAndGetters()
 {
     $state = new State('state1', StateInterface::TYPE_INITIAL, ['test_option' => 42]);
     $this->assertEquals('state1', $state->getName());
     $this->assertEquals(StateInterface::TYPE_INITIAL, $state->getType());
     $this->assertEquals(42, $state->getOption('test_option'));
     $this->assertTrue($state->isInitial());
     $this->assertFalse($state->isActive());
     $this->assertFalse($state->isFinal());
 }