src/Behavior/InclusiveChoiceBehavior.php
public function execute(Execution $execution)
    {
        if ($this->hasConcurrentActiveExecution($execution)) {
            return $execution->setActive(false);
        }
        
        $take = [];
        
        foreach ($execution->getProcessModel()->findOutgoingTransitions($execution->getNode()->getId()) as $trans) {
            if ($trans->getId() === $this->defaultTransition) {
                continue;
            }
            
            if ($trans->isEnabled($execution)) {
                $take[] = $trans;
            }
        }
        
        // Collect recycled executions, initialize with current execution:
        $recycle = [
            $execution->getTransition()->getId() => $execution
        ];
        
        foreach ($execution->findInactiveConcurrentExecutions($execution->getNode()) as $concurrent) {
            // Collect at most 1 execution per incoming transition.
            $transId = $concurrent->getTransition()->getId();
            
            if (empty($recycle[$transId]) || $concurrent->getTimestamp() < $recycle[$transId]->getTimestamp()) {
                $recycle[$transId] = $concurrent;
            }
        }
        
        if (!empty($take)) {
            return $execution->takeAll($take, $recycle);
        }
        
        if ($this->defaultTransition !== null) {
            return $execution->takeAll([
                $this->defaultTransition
            ], $recycle);
        }
        
        $message = sprintf('Execution %s about to get stuck in inclusive choice within node "%s"', $execution->getId(), $execution->getNode()->getId());
        
        throw new StuckException($message);
    }
public function execute(Execution $execution)
    {
        if ($this->hasConcurrentActiveExecution($execution)) {
            return $execution->setActive(false);
        }
        
        $take = [];
        
        foreach ($execution->getProcessModel()->findOutgoingTransitions($execution->getNode()->getId()) as $trans) {
            if ($trans->getId() === $this->defaultTransition) {
                continue;
            }
            
            if ($trans->isEnabled($execution)) {
                $take[] = $trans;
            }
        }
        
        // Collect recycled executions, initialize with current execution:
        $recycle = [
            $execution->getTransition()->getId() => $execution
        ];
        
        foreach ($execution->findInactiveConcurrentExecutions($execution->getNode()) as $concurrent) {
            // Collect at most 1 execution per incoming transition.
            $transId = $concurrent->getTransition()->getId();
            
            if (empty($recycle[$transId]) || $concurrent->getTimestamp() < $recycle[$transId]->getTimestamp()) {
                $recycle[$transId] = $concurrent;
            }
        }
        
        if (!empty($take)) {
            return $execution->takeAll($take, $recycle);
        }
        
        if ($this->defaultTransition !== null) {
            return $execution->takeAll([
                $this->defaultTransition
            ], $recycle);
        }
        
        $message = sprintf('Execution %s about to get stuck in inclusive choice within node "%s"', $execution->getId(), $execution->getNode()->getId());
        
        throw new StuckException($message);
    }
{@inheritdoc}