{@inheritDoc}

Defines the workflow sequence.
5414
public final void run(Closure templateCallback) {
		reset();
		setRunning();
		doSetup();
		while (processing()) {
			templateCallback.call(doWork());
		}
		setCompleted();
		doCleanup();
	}
380343
function(){
       var i; 
       for (i = 0; i < this._events.length; i++) {
           var evt = this._events[i];
           if (evt.eventType === "WorkflowExecutionCancelRequested") {
               return true;
           }
       }
       return false;

   }
605544
public function onAfterWrite()
    {
        $instance = $this->getWorkflowInstance();
        if ($instance && $instance->CurrentActionID) {
            $action = $instance->CurrentAction()->BaseAction()->targetUpdated($instance);
        }
    }
1067046
function setSequenceGenerator(\Tecnocreaciones\Bundle\ToolsBundle\Service\SequenceGenerator $sequenceGenerator) {
        $this->sequenceGenerator = $sequenceGenerator;
    }
1306911
public function define()
    {
        $this->eventEmitter->emit('suite.define', [$this]);
        call_user_func_array($this->getDefinition(), $this->getDefinitionArguments());
    }
66640
protected function initWorkflow()
    {
        $className = $this->workflowConfiguration['class']['name'];

        if (!class_exists($className, true)) {
            throw new StateMachineException('The class ' . $className . ' does not exist!', 100);
        }

        try {
            $this->workflow = new $className($this->workflowConfiguration);
        } catch (WorkflowException $ex) {
            throw new StateMachineException('Workflow with some problems', 90, $ex);
        }
    }
819800
@Override
    public Object mapSequence(Object sequence) {
        List<List<Integer>> seq = (List<List<Integer>>) sequence;
        List<Integer> ret = new ArrayList<>();
        for (List<Integer> step : seq)
            ret.add((Integer) map(step));
        return ret;
    }
1366122
public function createEnterWorkflowSequence($initalStatus, $sender)
	{
		$config = [
			'end'        => $initalStatus,
			'sender'  	 => $sender
		];
		return [
			'before' => [
				new WorkflowEvent(
					WorkflowEvent::beforeEnterWorkflow($initalStatus->getWorkflowId()),
					$config
				),
				new WorkflowEvent(
					WorkflowEvent::beforeEnterStatus($initalStatus->getId()),
					$config
				)
			],
			'after' => [
				new WorkflowEvent(
					WorkflowEvent::afterEnterWorkflow($initalStatus->getWorkflowId()),
					$config
				),
				new WorkflowEvent(
					WorkflowEvent::afterEnterStatus($initalStatus->getId()),
					$config
				)
			]
		];
	}
522673
public function initialize($instance, ServiceLocator $serviceLocator)
    {
        if ($instance instanceof WorkflowMessageHandler) {
            /** @var $env Environment */
            $env = $serviceLocator->get(Definition::SERVICE_ENVIRONMENT);

            $instance->useWorkflowEngine($env->getWorkflowEngine());
        }
    }
1247448
public function getDefinitionByID($object, $workflowID)
    {
        // Make sure the correct extensions have been applied to the data object.

        $workflow = null;
        if ($object->hasExtension(WorkflowApplicable::class)
            || $object->hasExtension(FileWorkflowApplicable::class)
        ) {
            // Validate the workflow ID against the data object.

            if (($object->WorkflowDefinitionID == $workflowID)
                || ($workflow = $object->AdditionalWorkflowDefinitions()->byID($workflowID))
            ) {
                if (is_null($workflow)) {
                    $workflow = DataObject::get_by_id(WorkflowDefinition::class, $workflowID);
                }
            }
        }
        return $workflow ? $workflow : null;
    }
1177398
public function onBeforeWrite()
    {
        if (!$this->Sort) {
            $this->Sort = DB::query('SELECT MAX("Sort") + 1 FROM "WorkflowDefinition"')->value();
        }
        if (!$this->ID && !$this->Title) {
            $this->Title = $this->getDefaultWorkflowTitle();
        }

        parent::onBeforeWrite();
    }
1260818
def _add_workflow(mcs, field_name, state_field, attrs):
        """"""
        attrs[field_name] = StateProperty(state_field.workflow, field_name)
203919
private void init(final Calendar definingCalendar) {
		patterns = new ArrayList<>();

		final StrategyParser fm = new StrategyParser(definingCalendar);
		for (;;) {
			final StrategyAndWidth field = fm.getNextStrategy();
			if (field == null) {
				break;
			}
			patterns.add(field);
		}
	}
689841
protected function initializeStates()
    {
        if (!array_key_exists('states', $this->vars)) {
            throw new WorkflowException("You must define some states:\n", 99, NULL);
        }

        //check if all the methods for each status is callable
        $methods_not_implemented = '';
        try {
            foreach ($this->vars['states'] as $status) {
                array_push($this->states, new Status($status));

                /*
                 * The initial state will never be executed but only the transitions, therefore it will be excluded
                 * from the list of methods which must be implemented
                 */
                if (!method_exists($this, $status['name'])
                    && $status['type'] != \Mothership\StateMachine\StatusInterface::TYPE_INITIAL
                    && $status['type'] != \Mothership\StateMachine\StatusInterface::TYPE_EXCEPTION) {
                    $methods_not_implemented .= $status['name'] . "\n";
                }
            }
        } catch (StatusException $ex) {
            throw new WorkflowException("Error in one state of the workflow:\n" . $ex->getMessage(), 79);
        }

        if (strlen($methods_not_implemented) > 0) {
            throw new WorkflowException(
                "This methods are not implemented in the workflow:\n" .
                $methods_not_implemented, 79, NULL
            );
        }
    }
1335668
protected function addStepNextStates(Definition $step, $stepsNextStates, $processName)
    {
        foreach ($stepsNextStates as $stateName => $data) {
            if (NextStateInterface::TYPE_STEP === $data['type']) {
                $step->addMethodCall('addNextState', array(
                    $stateName,
                    $data['type'],
                    new Reference(sprintf('lexik_workflow.process.%s.step.%s', $processName, $data['target']))
                ));

            } elseif (NextStateInterface::TYPE_STEP_OR === $data['type']) {
                $targets = array();

                foreach ($data['target'] as $stepName => $condition) {
                    $serviceId = null;
                    $method = null;

                    if (!empty($condition)) {
                        list($serviceId, $method) = explode(':', $condition);
                    }

                    $targets[] = array(
                        'target'           => new Reference(sprintf('lexik_workflow.process.%s.step.%s', $processName, $stepName)),
                        'condition_object' => null !== $serviceId ? new Reference($serviceId) : null,
                        'condition_method' => $method,
                    );
                }

                $step->addMethodCall('addNextStateOr', array($stateName, $data['type'], $targets));

            } elseif (NextStateInterface::TYPE_PROCESS === $data['type']) {
                $step->addMethodCall('addNextState', array(
                    $stateName,
                    $data['type'],
                    new Reference(sprintf('lexik_workflow.process.%s', $data['target']))
                ));

            } else {
                throw new \InvalidArgumentException(sprintf('Unknown type "%s", please use "step" or "process"', $data['type']));
            }
        }
    }
730295
@Override
	public int deferredEvents() {
		int ret = 0;
		if (!m_shuttingDown && !m_freeze) {
			List<DeferredEvent> deferredEvents;
			try {
				deferredEvents = getWorkflowDAO().getDeferredEvents();
			} catch (RuntimeException e) {
				return 0;
			}
			for (DeferredEvent deferredEvent: deferredEvents) {
				final DeferredEvent finalDeferredEvent = deferredEvent;
				ProcessInstance processInstance = finalDeferredEvent.getProcessInstance();
				getBundleSelector().selectBundle(processInstance);
				List<Lock> locks = ContextUtils.getLocks(processInstance,getLockFactory(),"nz.co.senanque.workflow.Executor.deferredEvents()");
				LockTemplate lockTemplate = new LockTemplate(locks, new LockAction() {
	
					public void doAction() {
						getWorkflowManager().executeDeferredEvent(finalDeferredEvent.getId());
					}});
				if (lockTemplate.doAction()) {
					ret++;
				}
			}
		}
		return ret;
	}
674750
public function buildCompiletimeSequence(): Sequence
    {
        $sequence = $this->buildEssentialsSequence('compiletime');

        $sequence->addStep(new Step('neos.flow:cachemanagement:forceflush', [Scripts::class, 'forceFlushCachesIfNecessary']), 'neos.flow:systemlogger');
        $sequence->addStep(new Step('neos.flow:objectmanagement:compiletime:create', [Scripts::class, 'initializeObjectManagerCompileTimeCreate']), 'neos.flow:systemlogger');
        $sequence->addStep(new Step('neos.flow:systemfilemonitor', [Scripts::class, 'initializeSystemFileMonitor']), 'neos.flow:objectmanagement:compiletime:create');
        $sequence->addStep(new Step('neos.flow:reflectionservice:factory', [Scripts::class, 'initializeReflectionServiceFactory']), 'neos.flow:systemfilemonitor');
        $sequence->addStep(new Step('neos.flow:reflectionservice', [Scripts::class, 'initializeReflectionService']), 'neos.flow:reflectionservice:factory');
        $sequence->addStep(new Step('neos.flow:objectmanagement:compiletime:finalize', [Scripts::class, 'initializeObjectManagerCompileTimeFinalize']), 'neos.flow:reflectionservice');
        return $sequence;
    }