You are here

public static function MaestroEngine::getProcessVariableID in Maestro 3.x

Same name and namespace in other branches
  1. 8.2 src/Engine/MaestroEngine.php \Drupal\maestro\Engine\MaestroEngine::getProcessVariableID()

Fetch the variable's unique ID from the variables table if it exists. Returns FALSE on not being able to find the variable.

Parameters

string $variableName: The variable's machine name you wish to retrieve the Unique ID for.

int $processID: The Maestro Process ID.

Return value

bool|mixed Returns a FALSE on failure or the variable's ID on success.

1 call to MaestroEngine::getProcessVariableID()
MaestroEngine::productionAssignments in src/Engine/MaestroEngine.php
Using the queueID, the task's machine name and the template machine name, we assign the task using the appropriate method defined in the template.

File

src/Engine/MaestroEngine.php, line 411

Class

MaestroEngine
Class MaestroEngine.

Namespace

Drupal\maestro\Engine

Code

public static function getProcessVariableID($variableName, $processID) {
  $query = \Drupal::entityTypeManager()
    ->getStorage('maestro_process_variables')
    ->getQuery();
  $query
    ->condition('process_id', $processID)
    ->condition('variable_name', $variableName);
  $entity_ids = $query
    ->execute();

  // We are expecting only 1 result... if any.
  $val = FALSE;
  if (count($entity_ids) > 0) {
    $entityID = current($entity_ids);
    $varRecord = \Drupal::entityTypeManager()
      ->getStorage('maestro_process_variables')
      ->resetCache([
      $entityID,
    ]);
    $varRecord = \Drupal::entityTypeManager()
      ->getStorage('maestro_process_variables')
      ->load($entityID);
    $val = $varRecord->id
      ->getString();
  }
  return $val;
}