function entity_metadata_comment_entity_property_info_alter in Entity API 7
Implements hook_entity_property_info_alter() on top of comment module.
See also
entity_entity_property_info_alter()
File
- modules/
comment.info.inc, line 131 - Provides info about the comment entity.
Code
function entity_metadata_comment_entity_property_info_alter(&$info) {
// Add info about comment module related properties to the node entity.
$properties =& $info['node']['properties'];
$properties['comment'] = array(
'label' => t("Comments allowed"),
'description' => t("Whether comments are allowed on this node: 0 = no, 1 = closed (read only), 2 = open (read/write)."),
'setter callback' => 'entity_property_verbatim_set',
'setter permission' => 'administer comments',
'type' => 'integer',
);
$properties['comments'] = array(
'label' => t("Comments"),
'type' => 'list<comment>',
'description' => t("The node comments."),
'getter callback' => 'entity_metadata_comment_get_node_properties',
'computed' => TRUE,
);
$properties['comment_count'] = array(
'label' => t("Comment count"),
'description' => t("The number of comments posted on a node."),
'getter callback' => 'entity_metadata_comment_get_node_properties',
'type' => 'integer',
);
$properties['comment_count_new'] = array(
'label' => t("New comment count"),
'description' => t("The number of comments posted on a node since the reader last viewed it."),
'getter callback' => 'entity_metadata_comment_get_node_properties',
'type' => 'integer',
);
// The comment body field is usually available for all bundles, so add it
// directly to the comment entity.
$info['comment']['properties']['comment_body'] = array(
'type' => 'text_formatted',
'label' => t('The main body text'),
'getter callback' => 'entity_metadata_field_verbatim_get',
'setter callback' => 'entity_metadata_field_verbatim_set',
'property info' => entity_property_text_formatted_info(),
'field' => TRUE,
'required' => TRUE,
);
unset($info['comment']['properties']['comment_body']['property info']['summary']);
}