public function updateworkflow($data, Form $form, $request)
    {
        /** @var WorkflowService $service */
        $service = singleton(WorkflowService::class);
        /** @var DataObject $record */
        $record = $form->getRecord();
        $workflow = $service->getWorkflowFor($record);
        if (!$workflow) {
            return null;
        }

        $action = $workflow->CurrentAction();

        if (!$record || !$record->canEditWorkflow()) {
            return null;
        }

        $allowedFields = $workflow->getWorkflowFields()->saveableFields();
        unset($allowedFields['TransitionID']);

        $allowed = array_keys($allowedFields);
        if (count($allowed)) {
            $form->saveInto($action, $allowed);
            $action->write();
        }

        if (isset($data['TransitionID']) && $data['TransitionID']) {
            $service->executeTransition($record, $data['TransitionID']);
        } else {
            // otherwise, just try to execute the current workflow to see if it
            // can now proceed based on user input
            $workflow->execute();
        }

        return $this->returnResponse($form);
    }
public function updateworkflow($data, Form $form, $request)
    {
        /** @var WorkflowService $service */
        $service = singleton(WorkflowService::class);
        /** @var DataObject $record */
        $record = $form->getRecord();
        $workflow = $service->getWorkflowFor($record);
        if (!$workflow) {
            return null;
        }

        $action = $workflow->CurrentAction();

        if (!$record || !$record->canEditWorkflow()) {
            return null;
        }

        $allowedFields = $workflow->getWorkflowFields()->saveableFields();
        unset($allowedFields['TransitionID']);

        $allowed = array_keys($allowedFields);
        if (count($allowed)) {
            $form->saveInto($action, $allowed);
            $action->write();
        }

        if (isset($data['TransitionID']) && $data['TransitionID']) {
            $service->executeTransition($record, $data['TransitionID']);
        } else {
            // otherwise, just try to execute the current workflow to see if it
            // can now proceed based on user input
            $workflow->execute();
        }

        return $this->returnResponse($form);
    }
public function updateworkflow ( $ data , Form $ form , $ request ) { /** @var WorkflowService $service */ $ service = singleton ( WorkflowService :: class ) ; /** @var DataObject $record */ $ record = $ form -> getRecord ( ) ; $ workflow = $ service -> getWorkflowFor ( $ record ) ; if ( ! $ workflow ) { return null ; } $ action = $ workflow -> CurrentAction ( ) ; if ( ! $ record || ! $ record -> canEditWorkflow ( ) ) { return null ; } $ allowedFields = $ workflow -> getWorkflowFields ( ) -> saveableFields ( ) ; unset ( $ allowedFields [ 'TransitionID' ] ) ; $ allowed = array_keys ( $ allowedFields ) ; if ( count ( $ allowed ) ) { $ form -> saveInto ( $ action , $ allowed ) ; $ action -> write ( ) ; } if ( isset ( $ data [ 'TransitionID' ] ) && $ data [ 'TransitionID' ] ) { $ service -> executeTransition ( $ record , $ data [ 'TransitionID' ] ) ; } else { // otherwise, just try to execute the current workflow to see if it // can now proceed based on user input $ workflow -> execute ( ) ; } return $ this -> returnResponse ( $ form ) ; }
Update a workflow based on user input.

@todo refactor with WorkflowInstance::updateWorkflow

@param array $data
@param Form $form
@param HTTPRequest $request
@return string|null
Update a workflow based on user input .