You are here

function entity_metadata_comment_setter in Entity API 7

Callback for setting comment properties.

See also

entity_metadata_comment_entity_info_alter()

1 string reference to 'entity_metadata_comment_setter'
entity_metadata_comment_entity_property_info in modules/comment.info.inc
Implements hook_entity_property_info() on top of comment module.

File

modules/callbacks.inc, line 76
Provides various callbacks for the whole core module integration.

Code

function entity_metadata_comment_setter($comment, $name, $value) {
  switch ($name) {
    case 'node':
      $comment->nid = $value;

      // Also set the bundle name.
      $node = node_load($value);
      $comment->node_type = 'comment_node_' . $node->type;
      break;
  }
}