function rules_action_entity_create

Action: Create entities.

Related topics

1 string reference to 'rules_action_entity_create'
rules_entity_action_info in modules/entity.rules.inc
Implements hook_rules_action_info() on behalf of the entity module.

File

modules/entity.eval.inc, line 91

Code

function rules_action_entity_create($args, $element) {
    $values = array();
    foreach ($element->pluginParameterInfo() as $name => $info) {
        if ($name != 'type') {
            // Remove the parameter name prefix 'param_'.
            $values[substr($name, 6)] = $args[$name];
        }
    }
    try {
        $data = entity_property_values_create_entity($args['type'], $values);
        return array(
            'entity_created' => $data,
        );
    } catch (EntityMetadataWrapperException $e) {
        throw new RulesEvaluationException('Unable to create entity @type: @message', array(
            '@type' => $args['type'],
            '@message' => $e->getMessage(),
        ), $element);
    }
}