izzum\statemachine\State::entryAction PHP Method

entryAction() public method

An entry action will not be executed for an 'initial' state.
public entryAction ( Context $context )
$context Context
    public function entryAction(Context $context)
    {
        $command = $this->getCommand($this->getEntryCommandName(), $context);
        $this->execute($command);
        $this->callCallable($this->getEntryCallable(), $context, self::CALLABLE_ENTRY);
    }

Usage Example

 /**
  * @test
  */
 public function shouldFailEntryAndExitWithNonCallable()
 {
     $state = new State('a');
     $context = new Context(new Identifier('123', 'foo-machine'));
     $event = 'foo';
     $callable = "Foo::BarEntry";
     $state->setEntryCallable($callable);
     $callable = "Foo::BarExit";
     $state->setExitCallable($callable);
     try {
         $state->entryAction($context);
         $this->fail('should not come here');
     } catch (Exception $e) {
         $this->assertEquals(Exception::CALLABLE_FAILURE, $e->getCode());
     }
     try {
         $state->exitAction($context);
         $this->fail('should not come here');
     } catch (Exception $e) {
         $this->assertEquals(Exception::CALLABLE_FAILURE, $e->getCode());
     }
 }
All Usage Examples Of izzum\statemachine\State::entryAction