/** * @param ContextInterface $context * @return int */ protected function getStatusSets(ContextInterface $context, $onlyContinuous = true) { $statusHistory = $context->getStateHistory(); $historySize = count($statusHistory); $count = 1; if ($onlyContinuous) { while (++$count <= $historySize && $statusHistory[$historySize - $count] === $context->getCurrentState()) { } } else { foreach ($statusHistory as $status) { if ($status === $context->getCurrentState()) { $count++; } } } return $count - 1; }
/** * @param ContextInterface $context * @param string $variableName * @param array $options * @return bool */ public function contentIn(ContextInterface $context, $variableName, array $options) { return in_array($context->getVariable($variableName), $options); }
/** * @param ContextInterface $context * @param array $workingDefinition * @param string $stateActionType * @throws InvalidRunnableExpressionException * @throws \Exception */ protected function runStateActions(ContextInterface $context, array $workingDefinition, $stateActionType) { $raiseEventQueue = []; if (isset($workingDefinition[$context->getCurrentState()][$stateActionType])) { foreach ($workingDefinition[$context->getCurrentState()][$stateActionType] as $stateTypeAction) { if (isset($stateTypeAction['action'])) { $this->runCommand($context, $this->actions, $stateTypeAction['action'], WorkflowEvents::ON_ACTION_ERROR); } elseif (isset($stateTypeAction['raise'])) { $raiseEventQueue[] = $stateTypeAction['raise']; } } } if (count($raiseEventQueue)) { while ($context->getParentContext()) { $context = $context->getParentContext(); } foreach ($raiseEventQueue as $raiseEvent) { $this->execute($context, $raiseEvent); } } }
/** * @param ContextInterface $context */ public function finish(ContextInterface $context) { $context->finish(); }