You are here

function rules_get_element_arguments in Rules 6

Gets the arguments as defined by the element.

Returns the arguments, which may have been specified using the data type's input form or by mapping to a state variable. Else a possible defined default value is returned.

Parameters

$element: The element to get arguments for.

$state: The current evalutation state.

Return value

An array of argument values. If it's not possible to get all arguments, FALSE will be returned.

1 call to rules_get_element_arguments()
rules_get_execution_arguments in rules/rules.variables.inc
Returns the execution arguments needed by the given element It applies the input evaluators and the #argument map and gets all needed arguments.

File

rules/rules.variables.inc, line 82
Provides functions and classes for handling variables

Code

function rules_get_element_arguments($element, &$state) {
  $element_info = rules_get_element_info($element);
  $map = rules_get_mapped_argument_names($element);
  $args = array();
  foreach (array_keys($element_info['arguments']) as $key => $name) {
    if (($var = rules_get_element_variable($element, $name)) !== NULL) {
      $args[$key] = $var;
    }
    elseif (isset($map[$name]) && isset($state['variables'][$map[$name]])) {
      $args[$key] =& $state['variables'][$map[$name]]
        ->get();
    }
    elseif (array_key_exists('default value', $element_info['arguments'][$name])) {
      $args[$key] = $element_info['arguments'][$name]['default value'];
    }
    else {
      rules_log(t('Warning: Unable to get argument "@name".', array(
        '@name' => $key,
      )));
      return FALSE;
    }
  }
  return $args;
}