public function startWorkflow(DataObject $object, $workflowID = null)
    {
        $existing = $this->getWorkflowFor($object);
        if ($existing) {
            throw new ExistingWorkflowException(_t(
                'WorkflowService.EXISTING_WORKFLOW_ERROR',
                "That object already has a workflow running"
            ));
        }

        $definition = null;
        if ($workflowID) {
            // Retrieve the workflow definition that has been triggered.

            $definition = $this->getDefinitionByID($object, $workflowID);
        }
        if (is_null($definition)) {
            // Fall back to the main workflow definition.

            $definition = $this->getDefinitionFor($object);
        }

        if ($definition) {
            $instance = new WorkflowInstance();
            $instance->beginWorkflow($definition, $object);
            $instance->execute();
        }
    }
public function startWorkflow(DataObject $object, $workflowID = null)
    {
        $existing = $this->getWorkflowFor($object);
        if ($existing) {
            throw new ExistingWorkflowException(_t(
                'WorkflowService.EXISTING_WORKFLOW_ERROR',
                "That object already has a workflow running"
            ));
        }

        $definition = null;
        if ($workflowID) {
            // Retrieve the workflow definition that has been triggered.

            $definition = $this->getDefinitionByID($object, $workflowID);
        }
        if (is_null($definition)) {
            // Fall back to the main workflow definition.

            $definition = $this->getDefinitionFor($object);
        }

        if ($definition) {
            $instance = new WorkflowInstance();
            $instance->beginWorkflow($definition, $object);
            $instance->execute();
        }
    }
public function startWorkflow ( DataObject $ object , $ workflowID = null ) { $ existing = $ this -> getWorkflowFor ( $ object ) ; if ( $ existing ) { throw new ExistingWorkflowException ( _t ( 'WorkflowService.EXISTING_WORKFLOW_ERROR' , "That object already has a workflow running" ) ) ; } $ definition = null ; if ( $ workflowID ) { // Retrieve the workflow definition that has been triggered. $ definition = $ this -> getDefinitionByID ( $ object , $ workflowID ) ; } if ( is_null ( $ definition ) ) { // Fall back to the main workflow definition. $ definition = $ this -> getDefinitionFor ( $ object ) ; } if ( $ definition ) { $ instance = new WorkflowInstance ( ) ; $ instance -> beginWorkflow ( $ definition , $ object ) ; $ instance -> execute ( ) ; } }
Starts the workflow for the given data object, assuming it or a parent has
a definition specified.

@param DataObject $object
@param int $workflowID
Starts the workflow for the given data object assuming it or a parent has a definition specified .