You are here

function workflow_get_workflow_names in Workflow 8

Same name and namespace in other branches
  1. 7.2 workflow.module \workflow_get_workflow_names()

Get an options list for workflows. Include an initial empty value if requested. Validate each workflow, and generate a message if not complete.

Parameters

bool $required: Indicates if the resulting list contains a options value.

Return value

array An array of $wid => workflow->label().

2 calls to workflow_get_workflow_names()
WorkflowItem::storageSettingsForm in src/Plugin/Field/FieldType/WorkflowItem.php
Implements hook_field_settings_form() -> ConfigFieldItemInterface::settingsForm().
WorkflowStateActionBase::buildConfigurationForm in src/Plugin/Action/WorkflowStateActionBase.php
Form constructor.

File

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

Code

function workflow_get_workflow_names($required = TRUE) {
  $options = [];
  if (!$required) {
    $options[''] = t('- Select a value -');
  }
  foreach (Workflow::loadMultiple() as $wid => $workflow) {

    /** @var \Drupal\workflow\Entity\Workflow $workflow */
    if ($workflow
      ->isValid()) {
      $options[$wid] = $workflow
        ->label();
    }
  }
  return $options;
}