Hi, apologies if this is not the right place for reporting this.
Working with the Comment module I needed to retrieve the parent entity author email, this is, the author email of the entity where the comment was originally posted. Now, there is a 'entity' token under the comment section list which retrieve the original node title, however, we have no access to any of the data related to this entity. Doing a research I found out that just changing the type of the 'entity' token to 'node' would be enough. I wrote a custom module with the following code
/**
* Implements hook_token_info_alter().
*/
function jtd_comment_tokens_token_info_alter(&$data) {
$data['tokens']['comment']['entity']['type'] = 'node';
}
Now, updating comment.tokens.inc file, line 104 would have the same effect
$comment['entity'] = [
'name' => t("Entity"),
'description' => t("The entity the comment was posted to."),
'type' => 'entity', // replace with: 'type' => 'node',
];
Hope this explanation is clear enough.
Thanks.
Comments
Comment #2
apadernoWith Drupal 8, it is possible to attach a comment reference field to every entity for which the field UI is enabled: admin/structure/comment allows to define a new content type; the field UI for the entity for which the comment type has been created allows to add a comment reference field.
Assuming that a comment is associated to a node is wrong.
What can eventually be done is defining tokens for the entity type. There would still the problem to access those properties that make sense for the entity, and not access [comment:entity:nid] when the comment has not been created for a node.