You are here

function workflow_entity_field_save in Workflow 7.2

Saves the workflow field, rather then the whole entity.

This is especially important when adding a new entity, and having an extra activity:

  • a Rules action after adding, cloning an entity (#2425453, #2550719)
  • revisions are expected after each update. (#2563125)

Parameters

$entity_type:

$entity:

$field_name:

$langcode:

$value:

1 call to workflow_entity_field_save()
workflow_execute_transition in ./workflow.module
Executes a transition (change state of a node), from outside the node, e.g., workflow_cron().

File

./workflow.module, line 503
Support workflows made up of arbitrary states.

Code

function workflow_entity_field_save($entity_type, $entity, $field_name, $langcode, $value) {
  if ($value !== FALSE) {
    $entity->{$field_name}[$langcode][0]['workflow'] = $value;
  }

  //  entity_save($entity_type, $entity);
  field_attach_presave($entity_type, $entity);
  field_attach_update($entity_type, $entity);
  if ($entity_type == 'node') {

    // Rebuild node access - necessary if using workflow access.
    node_access_acquire_grants($entity);

    // Manually clearing entity cache.
    entity_get_controller($entity_type)
      ->resetCache(array(
      $entity->nid,
    ));
  }
}