You are here

function Workflow::getFirstSid in Workflow 7

Same name and namespace in other branches
  1. 7.2 includes/Entity/Workflow.php \Workflow::getFirstSid()

Get the first valid state ID, after the creation state. Use WorkflowState::getOptions(), because this does a access check.

File

includes/Entity/Workflow.php, line 258
Contains workflow\includes\Entity\Workflow.

Class

Workflow
@file Contains workflow\includes\Entity\Workflow.

Code

function getFirstSid($entity_type, $entity) {
  $creation_state = $this
    ->getCreationState();
  $options = $creation_state
    ->getOptions($entity_type, $entity);
  if ($options) {
    $keys = array_keys($options);
    $sid = $keys[0];
  }
  else {

    // This should never happen, but it did during testing.
    drupal_set_message(t('There are no workflow states available. Please notify your site administrator.'), 'error');
    $sid = 0;
  }
  return $sid;
}