You are here

public function Workflow::getFirstSid in Workflow 7.2

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

Gets the first valid state ID, after the creation state.

Uses WorkflowState::getOptions(), because this does a access check. The first State ID is user-dependent!

Overrides WorkflowInterface::getFirstSid

File

includes/Entity/Workflow.php, line 410
Contains workflow\includes\Entity\Workflow. Contains workflow\includes\Entity\WorkflowController.

Class

Workflow

Code

public function getFirstSid($entity_type, $entity, $field_name, $user, $force) {
  $creation_state = $this
    ->getCreationState();
  $options = $creation_state
    ->getOptions($entity_type, $entity, $field_name, $user, $force);
  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;
}