protected function WorkflowItem::_allowed_values_string in Workflow 7.2
Same name and namespace in other branches
- 7 includes/Field/WorkflowItem.php \WorkflowItem::_allowed_values_string()
Helper functions for the Field Settings page.
Generates a string representation of an array of 'allowed values'. This is a copy from list.module's list_allowed_values_string(). The string format is suitable for edition in a textarea.
Parameters
int $wid: The Workflow Id.
Return value
string The string representation of the $values array:
- Values are separated by a carriage return.
- Each value is in the format "value|label" or "value".
1 call to WorkflowItem::_allowed_values_string()
- WorkflowItem::settingsForm in includes/
Field/ WorkflowItem.php - Implements hook_field_settings_form() -> ConfigFieldItemInterface::settingsForm().
File
- includes/
Field/ WorkflowItem.php, line 286 - Contains workflow\includes\Field\WorkflowItem.
Class
- WorkflowItem
- Plugin implementation of the 'workflow' field type.
Code
protected function _allowed_values_string($wid = 0) {
$lines = array();
$states = workflow_state_load_multiple($wid);
$previous_wid = -1;
/* @var $state WorkflowState */
foreach ($states as $state) {
// Only show enabled states.
if ($state
->isActive()) {
// Show a Workflow name between Workflows, if more then 1 in the list.
if ($wid == 0 && $previous_wid != $state->wid) {
$previous_wid = $state->wid;
$lines[] = $state->name . "'s states: ";
}
$label = $state
->label();
$states[$state->sid] = $label;
$lines[] = $state->sid . ' | ' . $label;
}
}
return implode("\n", $lines);
}