コード例 #1
0
 /**
  * Constructor
  *
  * @param State      $state    State the caused the exception
  * @param string     $setName  Name of the state the object was expecting
  * @param \Exception $previous Optional previous exception
  */
 public function __construct(State $state, $setName, \Exception $previous = null)
 {
     // Call the super constructor
     parent::__construct(sprintf('Trying to set state with name "%s" when object was expecting a state with name "%s"', $state->getName(), $setName), 0, $previous);
     // Set the properties
     $this->state = $state;
     $this->setName = $setName;
 }
コード例 #2
0
ファイル: StateTest.php プロジェクト: tyhand/workflow-bundle
 public function testGetName()
 {
     $state = new State('test');
     $this->assertEquals('test', $state->getName());
 }
コード例 #3
0
 /**
  * Set the value of The followup state
  *
  * @param State state
  *
  * @return self
  */
 public function setState(State $state)
 {
     if ($state->getName() === $this->stateName) {
         $this->state = $state;
     } else {
         throw new StateDoesNotMatchNameException($state, $this->stateName);
     }
     return $this;
 }
コード例 #4
0
ファイル: Workflow.php プロジェクト: tyhand/workflow-bundle
 /**
  * Add a state to the workflow
  *
  * @param State $state State
  *
  * @return self
  */
 public function addState(State $state)
 {
     // Check for name uniqueness
     if (array_key_exists($state->getName(), $this->states)) {
         throw new StateNameAlreadyUsedException($state->getName());
     }
     $this->states[$state->getName()] = $state;
     return $this;
 }
コード例 #5
0
 /**
  * Get the name of the state being built
  *
  * @return string State name
  */
 public function getStateName()
 {
     return $this->state->getName();
 }