Dropdown.php in Open Social 8.3
File
themes/socialbase/src/Plugin/Preprocess/Dropdown.php
View source
<?php
namespace Drupal\socialbase\Plugin\Preprocess;
use Drupal\bootstrap\Utility\Variables;
use Drupal\bootstrap\Utility\Unicode;
use Drupal\bootstrap\Plugin\Preprocess\BootstrapDropdown;
class Dropdown extends BootstrapDropdown {
public function preprocess(array &$variables, $hook, array $info) {
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 = !!Unicode::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. |