You are here

function social_landing_page_preprocess_node in Open Social 8.2

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_node()
  2. 8 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_node()
  3. 8.3 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_node()
  4. 8.4 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_node()
  5. 8.5 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_node()
  6. 8.6 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_node()
  7. 8.7 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_node()
  8. 8.8 modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_node()
  9. 10.3.x modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_node()
  10. 10.0.x modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_node()
  11. 10.1.x modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_node()
  12. 10.2.x modules/social_features/social_landing_page/social_landing_page.module \social_landing_page_preprocess_node()

Implements hook_preprocess_HOOK().

File

modules/social_features/social_landing_page/social_landing_page.module, line 178
The Social landing page module.

Code

function social_landing_page_preprocess_node(&$variables) {

  /** @var \Drupal\node\Entity\Node $node */
  $node = $variables['node'];
  if ($node
    ->getType() === 'landing_page') {

    // If featured we need to do some magic.
    if ($variables['view_mode'] === 'featured') {
      $variables['content']['field_landing_page_image'] = [
        '#type' => 'markup',
        '#markup' => _social_landing_page_get_hero_image($node),
      ];
    }

    // Get current user.
    $account = \Drupal::currentUser();

    // Add node edit url for management.
    if ($node instanceof NodeInterface) {

      // Get the current route name to check if the user is on the
      // edit or delete page.
      $route = \Drupal::routeMatch()
        ->getRouteName();
      if (!in_array($route, [
        'entity.node.edit_form',
        'entity.node.delete_form',
      ])) {
        if ($node
          ->access('update', $account)) {
          $variables['node_edit_url'] = $node
            ->toUrl('edit-form')
            ->toString();
        }
      }
    }
  }
}