public function updateWorkflow($data)
    {
        $action = $this->CurrentAction();

        if (!$this->getTarget() || !$this->getTarget()->canEditWorkflow()) {
            return;
        }

        $allowedFields = $this->getWorkflowFields()->saveableFields();
        unset($allowedFields['TransitionID']);
        foreach ($allowedFields as $field) {
            $fieldName = $field->getName();
            $action->$fieldName = $data[$fieldName];
        }
        $action->write();

        $svc = singleton(WorkflowService::class);
        if (isset($data['TransitionID']) && $data['TransitionID']) {
            $svc->executeTransition($this->getTarget(), $data['TransitionID']);
        } else {
            // otherwise, just try to execute the current workflow to see if it
            // can now proceed based on user input
            $this->execute();
        }
    }
public function updateWorkflow($data)
    {
        $action = $this->CurrentAction();

        if (!$this->getTarget() || !$this->getTarget()->canEditWorkflow()) {
            return;
        }

        $allowedFields = $this->getWorkflowFields()->saveableFields();
        unset($allowedFields['TransitionID']);
        foreach ($allowedFields as $field) {
            $fieldName = $field->getName();
            $action->$fieldName = $data[$fieldName];
        }
        $action->write();

        $svc = singleton(WorkflowService::class);
        if (isset($data['TransitionID']) && $data['TransitionID']) {
            $svc->executeTransition($this->getTarget(), $data['TransitionID']);
        } else {
            // otherwise, just try to execute the current workflow to see if it
            // can now proceed based on user input
            $this->execute();
        }
    }
public function updateWorkflow ( $ data ) { $ action = $ this -> CurrentAction ( ) ; if ( ! $ this -> getTarget ( ) || ! $ this -> getTarget ( ) -> canEditWorkflow ( ) ) { return ; } $ allowedFields = $ this -> getWorkflowFields ( ) -> saveableFields ( ) ; unset ( $ allowedFields [ 'TransitionID' ] ) ; foreach ( $ allowedFields as $ field ) { $ fieldName = $ field -> getName ( ) ; $ action -> $ fieldName = $ data [ $ fieldName ] ; } $ action -> write ( ) ; $ svc = singleton ( WorkflowService :: class ) ; if ( isset ( $ data [ 'TransitionID' ] ) && $ data [ 'TransitionID' ] ) { $ svc -> executeTransition ( $ this -> getTarget ( ) , $ data [ 'TransitionID' ] ) ; } else { // otherwise, just try to execute the current workflow to see if it // can now proceed based on user input $ this -> execute ( ) ; } }
Update the current state of the workflow

Typically, this is triggered by someone modifiying the workflow instance via the modeladmin form
side of things when administering things, such as re-assigning or manually approving a stuck workflow

Note that this is VERY similar to AdvancedWorkflowExtension::updateworkflow
but without the formy bits. These two implementations should PROBABLY
be merged

@todo refactor with AdvancedWorkflowExtension

@param type $data
@return
Update the current state of the workflow