예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function handle(Item $item, $transitionName = null)
 {
     $entity = $item->getEntity();
     $workflow = $this->getWorkflow($item->getEntityId(), $entity);
     if (!$workflow) {
         return false;
     }
     $this->guardSameWorkflow($item, $workflow);
     $handler = $this->handlerFactory->createTransitionHandler($item, $workflow, $transitionName, $item->getEntityId()->getProviderName(), $this->stateRepository);
     return $handler;
 }
예제 #2
0
 function it_creates_handler_for_ongoing_transition(Workflow $workflow, Item $item, TransitionHandlerFactory $transitionHandlerFactory, EntityId $entityId, StateRepository $stateRepository, TransitionHandler $transitionHandler, Transition $transition, Step $step)
 {
     $step->getName()->willReturn('start');
     $step->isTransitionAllowed('next')->willReturn(true);
     $item->getEntityId()->willReturn($entityId);
     $item->getEntity()->willReturn(static::$entity);
     $item->isWorkflowStarted()->willReturn(true);
     $item->getCurrentStepName()->willReturn('start');
     $item->getWorkflowName()->willReturn('workflow_a');
     $workflow->match($entityId, static::$entity)->willReturn(true);
     $workflow->getStep('start')->willReturn($step);
     $workflow->getTransition('next')->willReturn($transition);
     $workflow->getName()->willReturn('workflow_a');
     $entityId->getProviderName()->willReturn(static::ENTITY_PROVIDER_NAME);
     $transitionHandlerFactory->createTransitionHandler($item, $workflow, Argument::any(), static::ENTITY_PROVIDER_NAME, $stateRepository)->willReturn($transitionHandler);
     $this->handle($item, 'next')->shouldReturn($transitionHandler);
 }