function entity_metadata_comment_get_node_properties in Entity API 7
Callback for getting comment related node properties.
See also
entity_metadata_comment_entity_info_alter()
1 string reference to 'entity_metadata_comment_get_node_properties'
- entity_metadata_comment_entity_property_info_alter in modules/
comment.info.inc - Implements hook_entity_property_info_alter() on top of comment module.
File
- modules/
callbacks.inc, line 92 - Provides various callbacks for the whole core module integration.
Code
function entity_metadata_comment_get_node_properties($node, array $options, $name, $entity_type) {
switch ($name) {
case 'comment_count':
return isset($node->comment_count) ? $node->comment_count : 0;
case 'comment_count_new':
return comment_num_new($node->nid);
case 'comments':
$select = db_select('comment', 'c')
->fields('c', array(
'cid',
))
->condition('c.nid', $node->nid);
return array_keys($select
->execute()
->fetchAllKeyed(0, 0));
}
}