function rules_action_data_create
Action: Create data.
Related topics
1 string reference to 'rules_action_data_create'
- rules_data_action_info in modules/
data.rules.inc - Implements hook_rules_action_info() on behalf of the pseudo data module.
File
-
modules/
data.eval.inc, line 291
Code
function rules_action_data_create($args, $element) {
$type = $args['type'];
$values = array();
foreach ($element->pluginParameterInfo() as $name => $info) {
if ($name != 'type') {
// Remove the parameter name prefix 'param_'.
$values[substr($name, 6)] = $args[$name];
}
}
$cache = rules_get_cache();
$type_info = $cache['data_info'][$type];
if (isset($type_info['creation callback'])) {
try {
$data = $type_info['creation callback']($values, $type);
return array(
'data_created' => $data,
);
} catch (EntityMetadataWrapperException $e) {
throw new RulesEvaluationException('Unable to create @data: @message', array(
'@data' => $type,
'@message' => $e->getMessage(),
), $element);
}
}
else {
throw new RulesEvaluationException('Unable to create @data, no creation callback found.', array(
'@data' => $type,
), $element, RulesLog::ERROR);
}
}