function social_ajax_comments_ajax_comments_wrapper_id_alter in Open Social 10.0.x
Same name and namespace in other branches
- 8.9 modules/custom/social_ajax_comments/social_ajax_comments.module \social_ajax_comments_ajax_comments_wrapper_id_alter()
- 8.8 modules/custom/social_ajax_comments/social_ajax_comments.module \social_ajax_comments_ajax_comments_wrapper_id_alter()
- 10.3.x modules/custom/social_ajax_comments/social_ajax_comments.module \social_ajax_comments_ajax_comments_wrapper_id_alter()
- 10.1.x modules/custom/social_ajax_comments/social_ajax_comments.module \social_ajax_comments_ajax_comments_wrapper_id_alter()
- 10.2.x modules/custom/social_ajax_comments/social_ajax_comments.module \social_ajax_comments_ajax_comments_wrapper_id_alter()
Implements hook_ajax_comments_wrapper_id_alter().
File
- modules/
custom/ social_ajax_comments/ social_ajax_comments.module, line 124 - The Social AJAX comments module.
Code
function social_ajax_comments_ajax_comments_wrapper_id_alter(&$wrapper_html_id, ContentEntityInterface $commented_entity, $field_name) {
if ($commented_entity instanceof NodeInterface && $field_name === 'field_topic_comments') {
$wrapper_html_id = Html::getId(sprintf('%s-%s-%s', $commented_entity
->getEntityTypeId(), $commented_entity
->bundle(), $field_name));
}
elseif ($commented_entity instanceof PostInterface && $field_name === 'field_post_comments') {
$wrapper_html_id = Html::getId(sprintf('%s-%s-%s-%s', $commented_entity
->getEntityTypeId(), $commented_entity
->bundle(), $field_name, $commented_entity
->id()));
}
}