You are here

protected function WorkflowFeaturesController::pack_transitions in Workflow 7.2

"Packs" the transitions in the provided workflow into an export-friendly format.

Parameters

Workflow $workflow: The workflow to pack. The contents of this object are modified directly.

array $sid_to_name_map: The map of numeric state IDs to their machine names, for remapping sid references.

1 call to WorkflowFeaturesController::pack_transitions()
WorkflowFeaturesController::sanitize_workflow_for_export in ./workflow.features.inc
Prepares the provided workflow for export.

File

./workflow.features.inc, line 174
Provides Features integration for Workflow using the CRUD API.

Class

WorkflowFeaturesController
Default controller handling features integration.

Code

protected function pack_transitions(Workflow $workflow, array $sid_to_name_map) {
  $named_transitions = array();
  foreach ($workflow->transitions as $transition) {

    /* @var WorkflowTransition $transition */
    $start_name = $sid_to_name_map[$transition->sid];
    $end_name = $sid_to_name_map[$transition->target_sid];
    $new_name = WorkflowConfigTransition::machineName($start_name, $end_name);
    $transition->name = $new_name;
    $transition->start_state = $start_name;
    $transition->end_state = $end_name;

    // Eliminate serial IDs in exports to prevent "Overridden" status.
    // We use machine names instead.
    unset($transition->wid);
    unset($transition->tid);
    unset($transition->sid);
    unset($transition->target_sid);
    $named_transitions[$new_name] = $transition;
  }
  ksort($named_transitions);

  // Identify transitions by new machine name.
  $workflow->transitions = $named_transitions;
}