Exemplo n.º 1
0
 /**
  * Get transitions for existing workflow item.
  *
  * @param WorkflowItem $workflowItem
  * @return Collection|Transition[]
  * @throws UnknownStepException
  */
 public function getTransitionsByWorkflowItem(WorkflowItem $workflowItem)
 {
     $currentStepName = $workflowItem->getCurrentStep()->getName();
     $currentStep = $this->stepManager->getStep($currentStepName);
     if (!$currentStep) {
         throw new UnknownStepException($currentStepName);
     }
     $transitions = new ArrayCollection();
     $transitionNames = $currentStep->getAllowedTransitions();
     foreach ($transitionNames as $transitionName) {
         $transition = $this->transitionManager->extractTransition($transitionName);
         $transitions->add($transition);
     }
     return $transitions;
 }
Exemplo n.º 2
0
 public function testGetDefaultStartTransition()
 {
     $transitionsManager = new TransitionManager();
     $this->assertNull($transitionsManager->getDefaultStartTransition());
     $transition = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Model\\Transition')->disableOriginalConstructor()->getMock();
     $transition->expects($this->any())->method('getName')->will($this->returnValue(TransitionManager::DEFAULT_START_TRANSITION_NAME));
     $transitionsManager->setTransitions(new ArrayCollection(array($transition)));
     $this->assertEquals($transition, $transitionsManager->getDefaultStartTransition());
 }