You are here

public static function WorkflowTransition::loadMultiple in Workflow 7.2

Given a node, get all transitions for it.

Since this may return a lot of data, a limit is included to allow for only one result.

Parameters

string $entity_type:

array $entity_ids:

string $field_name: Optional. Can be NULL, if you want to load any field.

null $limit:

string $langcode:

Return value

array An array of WorkflowTransitions.

1 call to WorkflowTransition::loadMultiple()
workflow_transition_load_multiple in ./workflow.entity.inc
Load WorkflowTransitions, most recent first.

File

includes/Entity/WorkflowTransition.php, line 176
Contains workflow\includes\Entity\WorkflowTransition. Contains workflow\includes\Entity\WorkflowTransitionController.

Class

WorkflowTransition
Implements an actual Transition.

Code

public static function loadMultiple($entity_type, array $entity_ids, $field_name = '', $limit = NULL, $langcode = '') {
  $query = db_select('workflow_node_history', 'h');
  $query
    ->condition('h.entity_type', $entity_type);
  if ($entity_ids) {
    $query
      ->condition('h.nid', $entity_ids);
  }
  if ($field_name !== NULL) {

    // If we do not know/care for the field_name, fetch all history.
    // E.g., in workflow.tokens.
    $query
      ->condition('h.field_name', $field_name);
  }

  // Add selection on language.
  // Workflow Node: only has 'und'.
  // Workflow Field: untranslated field have 'und'.
  // Workflow Field: translated fields may be specified.
  if ($langcode) {
    $query
      ->condition('h.language', $langcode);
  }
  $query
    ->fields('h');

  // The timestamp is only granular to the second; on a busy site, we need the id.
  // $query->orderBy('h.stamp', 'DESC');
  $query
    ->orderBy('h.hid', 'DESC');
  if ($limit) {
    $query
      ->range(0, $limit);
  }
  $result = $query
    ->execute()
    ->fetchAll(PDO::FETCH_CLASS, 'WorkflowTransition');
  return $result;
}