function patterns_prepare_action in Patterns 7.2
Same name and namespace in other branches
- 7 includes/core/common.inc \patterns_prepare_action()
Preparing and validating the action tags as they are written in the pattern file. Concretely, it invokes operations 'prepare', and 'validate' on the pattern component.
@TODO Doc.
Parameters
array $actions An array of actions. Each action is an associative: array with keys 'action' and 'data'.
array $actions_map:
Return value
array $results array containing the description of eventual errors
2 calls to patterns_prepare_action()
- patterns_batch_action in includes/
core/ batch.inc - Executes a batch action.
- patterns_php_action in includes/
core/ php.inc - Execute a single pattern action.
File
- includes/
core/ common.inc, line 20 - The common functions used by the Batch and PHP running modes.
Code
function patterns_prepare_action(&$action, &$data) {
$status = PATTERNS_SUCCESS;
$message = '';
if (empty($action)) {
return patterns_results(PATTERNS_ERR, t('An unspecified error occurred. No valid action found'));
}
// Keep a list of which modules handle what tags.
$tag_modules = patterns_tagmodules_get_index($data);
if (!array_key_exists($data['tag'], $tag_modules)) {
$msg = t('<%tag> is not a valid tag', array(
'%tag' => $data['tag'],
));
return patterns_results(PATTERNS_ERR, $msg);
}
$err_prefix = t('Errors during pre-processing.');
/////////////////////////////////////////////
// Prepare actions for validation/processing
/////////////////////////////////////////////
$results = patterns_invoke('prepare', $action, $data);
if (!patterns_error_check_results($results, $err_prefix)) {
return $results;
}
$key =& $action;
$data =& $data;
//////////////////////////////////////////////////
// Validate tags with their appropriate components
//////////////////////////////////////////////////
$results = patterns_invoke('validate', $key, $data);
patterns_error_check_results($results, $err_prefix);
return $results;
}