You are here

public static function Workflow::getWorkflows in Workflow 7

18 calls to Workflow::getWorkflows()
Workflow::getWorkflowByName in includes/Entity/Workflow.php
A Factory function to get Workflow data from the database, and return objects. This is only called by CRUD functions in workflow.features.inc More than likely in prep for an import / export action. Therefore we don't want to fiddle with the…
Workflow::load in includes/Entity/Workflow.php
Loads a Workflow object from table {workflows} Implements a 'Factory' pattern to get Workflow data from the database, and return objects. The execution of the query instantiates objects and saves them in a static array.
WorkflowItem::getAllowedValues in includes/Field/WorkflowItem.php
WorkflowItem::settingsForm in includes/Field/WorkflowItem.php
workflow_access_features_export_options in workflow_access/workflow_access.features.inc
Implements hook_features_export_options().

... See full list

File

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

Class

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

Code

public static function getWorkflows($wid = 0, $reset = FALSE) {
  if ($reset) {
    self::$workflows = array();
  }
  if ($wid && isset(self::$workflows[$wid])) {

    // Only 1 is requested and cached: return this one.
    return array(
      $wid => self::$workflows[$wid],
    );
  }

  // Build the query.
  // If all are requested: read from db ($todo: cache this, but only used on Admin UI.)
  // If requested one is not cached: read from db
  $query = db_select('workflows', 'w');
  $query
    ->leftJoin('workflow_states', 'ws', 'w.wid = ws.wid');
  $query
    ->fields('w');
  $query
    ->addField('ws', 'sid', 'creation_sid');

  // Initially, only get the creation_state of the Workflow.
  $query
    ->condition('ws.sysid', WORKFLOW_CREATION);
  $query
    ->execute()
    ->fetchAll(PDO::FETCH_CLASS, 'Workflow');

  // return array of objects, even if only 1 is requested.
  // note: self::workflows[] is populated in respective constructors.
  if ($wid > 0) {

    // return 1 object.
    $workflow = isset(self::$workflows[$wid]) ? self::$workflows[$wid] : NULL;
    return array(
      $wid => $workflow,
    );
  }
  else {
    return self::$workflows;
  }
}