You are here

public function Dropdown::preprocess in Open Social 8.9

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

Preprocess theme hook variables.

Parameters

array $variables: The variables array, passed by reference (modify in place).

string $hook: The name of the theme hook.

array $info: The theme hook info array.

Overrides PreprocessBase::preprocess

File

themes/socialbase/src/Plugin/Preprocess/Dropdown.php, line 20

Class

Dropdown
Pre-processes variables for the "bootstrap_dropdown" theme hook.

Namespace

Drupal\socialbase\Plugin\Preprocess

Code

public function preprocess(array &$variables, $hook, array $info) {
  $operations = !!mb_strpos($variables['theme_hook_original'], 'operations');
  $route = \Drupal::routeMatch()
    ->getRouteName();
  if ($operations && ($route === 'view.event_manage_enrollments.page_manage_enrollments' || $route === 'view.group_manage_members.page_group_manage_members')) {
    $variables['default_button'] = FALSE;
    $variables['toggle_label'] = $this
      ->t('Actions');
  }
  if (isset($variables['attributes']['no-split'])) {
    $variables['default_button'] = FALSE;
    $variables['toggle_label'] = $variables['attributes']['no-split']['title'];
    $variables['alignment'] = $variables['attributes']['no-split']['alignment'];
  }
  parent::preprocess($variables, $hook, $info);
  if (isset($variables['items']['#items']['publish']['element']['#button_type']) && $variables['items']['#items']['publish']['element']['#button_type'] === 'primary') {
    $variables['alignment'] = 'right';
    if (isset($variables['toggle'])) {
      $variables['toggle']['#button_type'] = 'primary';
      $variables['toggle']['#button_level'] = 'raised';
    }
  }
}