You are here

function ca_load_trigger_arguments in Ubercart 6.2

Return a trigger's arguments formatted for select element options.

Parameters

$trigger: The name of the trigger to load arguments for.

$entity: The name of the entity type we must restrict our returned arguments to.

Return value

An array of arguments in FAPI options format.

2 calls to ca_load_trigger_arguments()
ca_actions_form in ca/ca.admin.inc
Build a form for adding and editing actions on a predicate.
_ca_conditions_form_condition in ca/ca.admin.inc
Add a single condition's fieldset to the conditions form.

File

ca/ca.module, line 555
This is a demonstration module for the new conditional actions API.

Code

function ca_load_trigger_arguments($trigger, $entity) {
  static $arguments = array();

  // Load the arguments if we can't find a cached version.
  if (!isset($arguments[$trigger][$entity])) {
    $arguments[$trigger][$entity] = array();

    // Handle the arguments entity specially, as it should never be specified
    // in a trigger.
    if ($entity == 'arguments') {
      $arguments[$trigger][$entity]['arguments'] = t('Arguments');
    }
    else {

      // Load the trigger data.
      $trigger_data = ca_load_trigger($trigger);

      // Add the trigger's arguments to the options array if the entity matches.
      foreach ((array) $trigger_data['#arguments'] as $key => $value) {
        if ($value['#entity'] == $entity) {
          $arguments[$trigger][$entity][$key] = $value['#title'];
        }
      }
    }
  }
  return $arguments[$trigger][$entity];
}