GroupSettingsHelp.php in Open Social 8.9
File
themes/socialbase/src/Plugin/Preprocess/GroupSettingsHelp.php
View source
<?php
namespace Drupal\socialbase\Plugin\Preprocess;
use Drupal\bootstrap\Bootstrap;
use Drupal\bootstrap\Plugin\Preprocess\PreprocessBase;
use Drupal\bootstrap\Plugin\Preprocess\PreprocessInterface;
use Drupal\bootstrap\Utility\Variables;
use Drupal\Component\Utility\Html;
use Drupal\Core\Url;
class GroupSettingsHelp extends PreprocessBase implements PreprocessInterface {
public function preprocessVariables(Variables $variables) {
$build = [];
$unique_id = Html::getUniqueId('group-settings-help');
$icon = Bootstrap::glyphicon('info-sign');
$build['toggle'] = [
'#type' => 'link',
'#title' => '',
'#url' => Url::fromUserInput("#{$unique_id}"),
'#icon' => $icon,
'#attributes' => [
'class' => [
'icon-before',
],
'data-toggle' => 'popover',
'data-html' => 'true',
'data-placement' => 'bottom',
'data-title' => $variables['group_type'],
],
];
$build['settings'] = [
'#type' => 'container',
'#theme_wrappers' => [
'container__group_settings_help',
],
];
$build['settings']['join_method'] = [
'#theme' => 'item_list__group_settings_help',
'#items' => $variables['join_method'],
'#title' => $this
->t('Method to join'),
];
$build['settings']['allowed_visibility'] = [
'#theme' => 'item_list__group_settings_help',
'#items' => $variables['allowed_visibility'],
'#title' => $this
->t('Content visibility'),
];
$variables['popover'] = $build;
$variables['popover_id'] = $unique_id;
$variables['popover_toggle'] = $build['toggle'];
$variables['popover_info'] = $build['settings'];
}
}