You are here

function workflow_transition in Workflow 7.2

Same name and namespace in other branches
  1. 5.2 workflow.module \workflow_transition()
  2. 6.2 workflow.module \workflow_transition()
  3. 6 workflow.module \workflow_transition()
  4. 7 workflow.module \workflow_transition()

Validate target state and either execute a transition immediately or schedule a transition to be executed later by cron.

@deprecated: workflow_transition --> WorkflowDefaultWidget::submit()

Parameters

object $entity:

string $new_sid: An integer; the target state ID.

bool $force: Allows bypassing permissions, primarily for Rules.

array $field: The field structure for the operation.

File

./workflow.deprecated.inc, line 237
Contains contains per-class functions, that are deprecated.

Code

function workflow_transition($entity, $new_sid, $force = FALSE, $field = array()) {
  $entity_type = 'node';

  // Entity support is in workflow_transition --> WorkflowDefaultWidget::submit()
  // @todo: do not use widget:submit directly, use workflow_entity_save instead.
  $widget = new WorkflowDefaultWidget($field, $instance = array(), $entity_type, $entity);
  $form = array();
  $form_state = array();
  $items = array();
  $items[0]['workflow'] = (array) $entity;
  $items[0]['workflow']['workflow_sid'] = $new_sid;
  $widget
    ->submit($form, $form_state, $items, $force);
}