function workflow_access_features_export_render in Workflow 7
Same name and namespace in other branches
- 7.2 workflow_access/workflow_access.features.inc \workflow_access_features_export_render()
Implements hook_features_export_render().
Instruct Features which php code to generate, including the code-ified workflow access records we want to export from db into code.
File
- workflow_access/
workflow_access.features.inc, line 79
Code
function workflow_access_features_export_render($module_name, $data, $export = NULL) {
$code = array();
$code[] = ' $workflows = array();';
// For each selected workflow, fetch all related workflow access records
// we want to put into code.
foreach ($data as $workflow_name) {
$workflow = Workflow::getWorkflowByName($workflow_name);
if ($workflow) {
$states = $workflow
->getStates($all = TRUE);
if ($states) {
$code[] = "\n \$workflows['{$workflow_name}'] = array();";
foreach ($states as $state) {
$access_records = workflow_access_get_features_workflow_access_by_sid($state->sid);
if (!empty($access_records)) {
$state_name = $state
->getName();
$code[] = " \$workflows['{$workflow_name}']['{$state_name}'] = array();";
foreach ($access_records as $record) {
$rname = $record->rname;
unset($record->rname);
$code[] = " \$workflows['{$workflow_name}']['{$state_name}']['{$rname}'] = " . features_var_export($record, ' ') . ';';
}
}
}
}
}
}
$code[] = "\n return \$workflows;";
$code = implode("\n", $code);
return array(
'workflow_access_features_default_settings' => $code,
);
}