Alterway\Component\Workflow\Node::getOpenTransitions PHP Méthode

getOpenTransitions() public méthode

Returns the opened transitions.
public getOpenTransitions ( Alterway\Component\Workflow\ContextInterface $context ) : array
$context Alterway\Component\Workflow\ContextInterface
Résultat array
    public function getOpenTransitions(ContextInterface $context)
    {
        $transitions = array();
        foreach ($this->transitions as $transition) {
            /** @var $transition Transition */
            if ($transition->isOpen($context)) {
                $transitions[] = $transition;
            }
        }
        return $transitions;
    }

Usage Example

 /**
  * Moves the current token to the next node of the workflow.
  *
  * @param ContextInterface $context
  *
  * @return Workflow
  *
  * @throws Exception\NotInitializedWorkflowException
  * @throws Exception\NoOpenTransitionException
  * @throws Exception\MoreThanOneOpenTransitionException
  */
 public function next(ContextInterface $context)
 {
     if (null === $this->current) {
         throw new Exception\NotInitializedWorkflowException();
     }
     $transitions = $this->current->getOpenTransitions($context);
     if (0 === count($transitions)) {
         throw new Exception\NoOpenTransitionException();
     } elseif (1 < count($transitions)) {
         throw new Exception\MoreThanOneOpenTransitionException();
     }
     $transition = array_pop($transitions);
     $token = $transition->getDestination()->getName();
     $this->initialize($token);
     $this->eventDispatcher->dispatch($token, new Event($context, $token));
     return $this;
 }