izzum\statemachine\persistence\Adapter::processSetState PHP Method

processSetState() public method

saves an object to a storage facility (either insert or update). Implement this method for specifying how you want to set a state in the storage facility. A storage facility could store a timestamp and the state the transition was made to, for extra statistical information. this method is public to be able to call it via the ReaderWriterDelegator
public processSetState ( Identifier $identifier, string $state, $message = null ) : boolean
$identifier izzum\statemachine\Identifier
$state string
return boolean true if just added to storage, false if stored before
    public function processSetState(Identifier $identifier, $state, $message = null)
    {
        if ($this->isPersisted($identifier)) {
            $this->addHistory($identifier, $state, $message);
            $this->updateState($identifier, $state, $message);
            return false;
        } else {
            $this->addHistory($identifier, $state, $message);
            $this->insertState($identifier, $state, $message);
            return true;
        }
    }

Usage Example

 public function processSetState(Identifier $identifier, $state, $message = null)
 {
     return $this->writer->processSetState($identifier, $state, $message);
 }