izzum\statemachine\StateMachine::setState PHP Méthode

setState() public méthode

This should only be done: - initially, right after a machine has been created, to set it in a certain state if the state has not been persisted before. - when changing context (since this resets the current state) via $machine->setState($machine->getCurrentState()) This method allows you to bypass the transition guards and the transition logic. no exit/entry/transition logic will be performed
public setState ( State $state, string $message = null )
$state State
$message string optional message. this can be used by the persistence adapter to be part of the transition history to provide extra information about the transition.
    public function setState(State $state, $message = null)
    {
        if ($this->getState($state->getName()) === null) {
            throw new Exception(sprintf("%s state '%s' not known to this machine", $this->toString(), $state->getName()), Exception::SM_UNKNOWN_STATE);
        }
        //get the state known to this machine so we are sure we have the correct reference
        //even if the client provides another instance of State with the same name
        $state = $this->getState($state->getName());
        $this->getContext()->setState($state->getName(), $message);
        $this->state = $state;
    }