You are here

function exclude_node_title_preprocess_page in Exclude Node Title 8

Same name and namespace in other branches
  1. 6 exclude_node_title.module \exclude_node_title_preprocess_page()
  2. 7 exclude_node_title.module \exclude_node_title_preprocess_page()

Implements hook_preprocess_page().

File

./exclude_node_title.module, line 105
Primarily Drupal hooks and global API functions to exclude node titles.

Code

function exclude_node_title_preprocess_page(&$vars) {
  if (!\Drupal::currentUser()
    ->hasPermission('use exclude node title')) {
    return;
  }
  $exclude_manager = \Drupal::service('exclude_node_title.manager');
  $route_match = \Drupal::routeMatch();
  $route_name = $route_match
    ->getRouteName();
  switch ($route_name) {
    case 'entity.node.edit_form':
      $node = $route_match
        ->getParameter('node');
      $exclude_manager
        ->preprocessTitle($vars, $node, 'nodeform');
      break;
    case 'entity.node.canonical':
      $node = $route_match
        ->getParameter('node');
      $exclude_manager
        ->preprocessTitle($vars, $node, 'full');
      break;
    case 'entity.node.preview':
      $node = $route_match
        ->getParameter('node_preview');
      if (exclude_node_title_check_perm($node)) {
        exclude_node_title_set_flag($node, $node->exclude_node_title);
      }
      $exclude_manager
        ->preprocessTitle($vars, $node, 'full');
      break;
  }
}