function social_post_preprocess_post in Open Social 10.1.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_post/social_post.module \social_post_preprocess_post()
- 8.8 modules/social_features/social_post/social_post.module \social_post_preprocess_post()
- 10.0.x modules/social_features/social_post/social_post.module \social_post_preprocess_post()
Implements hook_preprocess_HOOK().
File
- modules/
social_features/ social_post/ social_post.module, line 213 - The Social post module.
Code
function social_post_preprocess_post(&$variables) {
if ($variables['elements']['#view_mode']) {
/** @var \Drupal\social_post\Entity\PostInterface $entity */
$entity = $variables['elements']['#post'];
if (in_array($entity
->bundle(), [
'post',
'photo',
]) && \Drupal::routeMatch()
->getRouteName() === 'entity.node.canonical' && \Drupal::routeMatch()
->getParameter('node')
->bundle() === 'dashboard') {
$variables['dashboard'] = TRUE;
$variables['comment_count'] = $entity
->get('field_post_comments')->comment_count;
$variables['comment_url'] = $entity
->toUrl()
->toString();
}
}
}