Beispiel #1
0
 /**
  * @param string           $name         process/schema name
  * @param string           $subjectClass context class name
  * @param string           $initialState initial state for entities starting process
  * @param StateInterface[] $states
  *
  * @throws InvalidStateException
  */
 public function __construct($name, $subjectClass, $initialState, array $states)
 {
     $this->assertName($name);
     $this->name = $name;
     $this->subjectClass = $subjectClass;
     $this->initialState = $initialState;
     $this->states = new GenericCollection($states, '\\StateMachine\\StateInterface');
     if (!$this->states->has($this->initialState)) {
         throw new InvalidStateException(sprintf('Initial state "%s" does not exist in process "%s"', $this->initialState, $this->getName()));
     }
 }
Beispiel #2
0
 /**
  * Return true if event exists in collection
  *
  * @param string $name
  *
  * @return bool
  */
 public function hasEvent($name)
 {
     return $this->events->has($name);
 }