You are here

function social_post_preprocess_post in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/social_post.module \social_post_preprocess_post()
  2. 10.0.x modules/social_features/social_post/social_post.module \social_post_preprocess_post()
  3. 10.1.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 225
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();
    }
  }
}