I've had an awful time with features and SIDs being reassigned on import, so I've resolved to dynamically load SIDs from state names in all of my customizations that leverage workflow. Unfortunately, I cannot for the life of me figure out what function I would need to call to load a State Name by SID. I'm assuming there is such a function and that I wouldn't need to query the database for this info. Am I overlooking something?

Comments

Kcannick created an issue. See original summary.

johnv’s picture

Status: Active » Closed (duplicate)
Related issues: +#2760913: How to lookup SID by machine name
millerhun’s picture

Status: Closed (duplicate) » Active
Issue tags: +Not duplicate. The referenced issue is not about getting the state name from SID.
johnv’s picture

Check the workflow.module file:

/**
 * Get an options list for workflows (to show in a widget).
 *
 * To be used in non-OO modules.
 *
 * @return array $options
 *   An array of $wid => workflow->label().
 */
function workflow_get_workflow_names() {}
/**
 * Get an options list for workflow states (to show in a widget).
 *
 * To be used in non-OO modules, like workflow_rules.
 *
 * @param mixed $wid
 *   The Workflow ID.
 * @param bool $grouped
 *   Indicates if the value must be grouped per workflow.
 *   This influence the rendering of the select_list options.
 * @param bool $all
 *   Indicates to return all (TRUE) or active (FALSE) states of a workflow.
 *
 * @return array $options
 *   An array of $sid => state->label(), grouped per Workflow.
 */
function workflow_get_workflow_state_names($wid = 0, $grouped = FALSE, $all = FALSE) {}
 

Or in WorkflowState:

  /**
   * Get all states in the system, with options to filter, only where a workflow exists.
   *
   * @param $wid
   *   The requested Workflow ID.
   * @param bool $reset
   *   An option to refresh all caches.
   *
   * @return array $states
   *   An array of cached states.
   *
   * D7.x-2.x: deprecated workflow_get_workflow_states --> workflow_state_load_multiple
   * D7.x-2.x: deprecated workflow_get_workflow_states_all --> workflow_state_load_multiple
   * D7.x-2.x: deprecated workflow_get_other_states_by_sid --> workflow_state_load_multiple
   */
  public static function WorkflowState::getStates($wid = 0, $reset = FALSE) {}
garphy’s picture

Issue tags: -Not duplicate. The referenced issue is not about getting the state name from SID.