function ca_parse_trigger_args in Ubercart 6.2
Parse the argument array into a CA friendly array for the trigger.
Parameters
$trigger: The name of the trigger for which we are parsing the arguments.
$args: An array of arguments to check against the expected arguments.
Return value
The array of arguments keyed according to the trigger's argument names.
1 call to ca_parse_trigger_args()
- ca_pull_trigger in ca/
ca.module - Pull a trigger and evaluate any predicates associated with that trigger.
File
- ca/
ca.module, line 212 - This is a demonstration module for the new conditional actions API.
Code
function ca_parse_trigger_args($trigger, $args) {
// Fail if we didn't receive enough arguments for this trigger.
if (count($args) < count($trigger['#arguments'])) {
return FALSE;
}
// Load all the entity information.
$entities = module_invoke_all('ca_entity');
// Loop through the expected arguments.
foreach ($trigger['#arguments'] as $key => $value) {
// Grab for comparison the next argument passed to the trigger.
$arg = array_shift($args);
// Check the type and fail if it is incorrect.
if (gettype($arg) != $entities[$value['#entity']]['#type']) {
return FALSE;
}
// Add the entity to the arguments array along with its meta data.
$arguments[$key] = array(
'#entity' => $value['#entity'],
'#title' => $value['#title'],
'#data' => $arg,
);
}
return $arguments;
}