Dropdown.php in Open Social 8.5
File
themes/socialbase/src/Plugin/Preprocess/Dropdown.php
View source
<?php
namespace Drupal\socialbase\Plugin\Preprocess;
use Drupal\bootstrap\Utility\Variables;
use Drupal\bootstrap\Plugin\Preprocess\BootstrapDropdown;
class Dropdown extends BootstrapDropdown {
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');
}
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';
}
}
}
protected function preprocessLinks(Variables $variables) {
parent::preprocessLinks($variables);
$operations = !!mb_strpos($variables->theme_hook_original, 'operations');
if ($operations) {
$variables->toggle['#attributes']['class'] = [
'btn-sm',
];
$variables['btn_context'] = 'operations';
$variables['alignment'] = 'right';
}
}
}
Classes
Name |
Description |
Dropdown |
Pre-processes variables for the "bootstrap_dropdown" theme hook. |