示例#1
0
 /**
  * Adds a link to the workflow.
  *
  * @param string $src
  * @param string $dst
  * @param SpecificationInterface $spec
  *
  * @return Builder
  *
  * @throws Exception\NoStartingNodeBuilderException
  */
 public function link($src, $dst, SpecificationInterface $spec)
 {
     if (null === $this->start) {
         throw new Exception\NoStartingNodeBuilderException();
     }
     $this->nodes->get($src)->addTransition($this->nodes->get($dst), $spec);
     return $this;
 }
示例#2
0
 /**
  * Initializes the workflow with a given token.
  *
  * @param string $token
  *
  * @return Workflow
  *
  * @throws Exception\InvalidTokenException
  */
 public function initialize($token = null)
 {
     if (null === $token) {
         $this->current = $this->start;
     } elseif ($this->nodes->has($token)) {
         $this->current = $this->nodes->get($token);
     } else {
         throw new Exception\InvalidTokenException();
     }
     return $this;
 }