You are here

public function MenuLocalAction::preprocessElement in Open Social 8.7

Same name and namespace in other branches
  1. 8.9 themes/socialbase/src/Plugin/Preprocess/MenuLocalAction.php \Drupal\socialbase\Plugin\Preprocess\MenuLocalAction::preprocessElement()
  2. 8 themes/socialbase/src/Plugin/Preprocess/MenuLocalAction.php \Drupal\socialbase\Plugin\Preprocess\MenuLocalAction::preprocessElement()
  3. 8.2 themes/socialbase/src/Plugin/Preprocess/MenuLocalAction.php \Drupal\socialbase\Plugin\Preprocess\MenuLocalAction::preprocessElement()
  4. 8.3 themes/socialbase/src/Plugin/Preprocess/MenuLocalAction.php \Drupal\socialbase\Plugin\Preprocess\MenuLocalAction::preprocessElement()
  5. 8.4 themes/socialbase/src/Plugin/Preprocess/MenuLocalAction.php \Drupal\socialbase\Plugin\Preprocess\MenuLocalAction::preprocessElement()
  6. 8.5 themes/socialbase/src/Plugin/Preprocess/MenuLocalAction.php \Drupal\socialbase\Plugin\Preprocess\MenuLocalAction::preprocessElement()
  7. 8.6 themes/socialbase/src/Plugin/Preprocess/MenuLocalAction.php \Drupal\socialbase\Plugin\Preprocess\MenuLocalAction::preprocessElement()
  8. 8.8 themes/socialbase/src/Plugin/Preprocess/MenuLocalAction.php \Drupal\socialbase\Plugin\Preprocess\MenuLocalAction::preprocessElement()

Preprocess the variables array if an element is present.

Parameters

\Drupal\bootstrap\Utility\Element $element: The Element object.

\Drupal\bootstrap\Utility\Variables $variables: The Variables object.

Overrides MenuLocalAction::preprocessElement

File

themes/socialbase/src/Plugin/Preprocess/MenuLocalAction.php, line 21

Class

MenuLocalAction
Pre-processes variables for the "menu_local_action" theme hook.

Namespace

Drupal\socialbase\Plugin\Preprocess

Code

public function preprocessElement(Element $element, Variables $variables) {
  parent::preprocessElement($element, $variables);
  $route_names = [
    // Identify the `Add member` button on the manage members page of a group.
    'view.group_manage_members.page_group_manage_members',
    // Identify the `Add enrollee` button on the manage enrollments page.
    'view.event_manage_enrollments.page_manage_enrollments',
    // Identify the `New message` button on the private message page.
    'entity.private_message_thread.canonical',
  ];
  if (in_array(\Drupal::routeMatch()
    ->getRouteName(), $route_names)) {
    $variables['link']['#options']['attributes']['class'] = 'btn btn-primary btn-raised';
    $variables['attributes']['class'][] = 'margin-bottom-l';
  }
}