protected function WorkflowFeaturesController::pack_states in Workflow 7.2
"Packs" the states in the provided workflow into an export-friendly format.
Parameters
Workflow $workflow: The workflow to pack. The contents of this object are modified directly.
Return value
array A map of the old state IDs to their new machine names.
1 call to WorkflowFeaturesController::pack_states()
- WorkflowFeaturesController::sanitize_workflow_for_export in ./
workflow.features.inc - Prepares the provided workflow for export.
File
- ./
workflow.features.inc, line 139 - Provides Features integration for Workflow using the CRUD API.
Class
- WorkflowFeaturesController
- Default controller handling features integration.
Code
protected function pack_states(Workflow $workflow) {
$named_states = array();
$sid_to_name_map = array();
foreach ($workflow->states as $state) {
/* @var WorkflowState $state */
$name = $state
->getName();
$sid_to_name_map[$state->sid] = $name;
// Eliminate serial IDs in exports to prevent "Overridden" status.
// We use machine names instead.
unset($state->sid);
unset($state->wid);
$named_states[$name] = $state;
}
ksort($named_states);
// Identify states by machine name.
$workflow->states = $named_states;
return $sid_to_name_map;
}