Newer
Older
* Functions to support theming in the Bootstrap Barrio theme.
use Drupal\Component\Utility\Html;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Component\Utility\Xss;

Ridhima Abrol
committed
use Drupal\Component\Render\MarkupInterface;
/**
* Implements hook_preprocess_HOOK() for HTML document templates.
*
* Adds body classes if certain regions have content.
*/
function bootstrap_barrio_preprocess_html(&$variables) {
if (!isset($variables['attributes']['class'])) {

Nicolas Haase
committed
$variables['attributes']['class'] = [];
}
// Add information about the number of sidebars.
if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {
$variables['attributes']['class'][] = 'layout-two-sidebars';
}
elseif (!empty($variables['page']['sidebar_first'])) {
$variables['attributes']['class'][] = 'layout-one-sidebar';
$variables['attributes']['class'][] = 'layout-sidebar-first';
}
elseif (!empty($variables['page']['sidebar_second'])) {
$variables['attributes']['class'][] = 'layout-one-sidebar';
$variables['attributes']['class'][] = 'layout-sidebar-second';
}
else {
$variables['attributes']['class'][] = 'layout-no-sidebars';
}
if (!empty($variables['page']['featured_top'])) {
$variables['attributes']['class'][] = 'has-featured-top';
}
// Scroll Spy info added to body.
if ($scroll_spy = theme_get_setting('bootstrap_barrio_scroll_spy')) {
$variables['attributes']['data-target'] = $scroll_spy;
$variables['attributes']['data-spy'] = "scroll";
}
// Page specific info.
$variables['path_info']['args'] = FALSE;
$path = \Drupal::service('path.current')->getPath();
$path = ltrim($path, '/');
$path_args = explode('/', $path);
if (isset($path_args[0]) && isset($path_args[1]) && ($path_args[0] == 'node') && (is_numeric($path_args[1]))) {
$variables['attributes']['class'][] = 'page-node-' . $path_args[1];
}
if (isset($path_args[0]) && isset($path_args[1]) && ($path_args[0] == 'user')) {
$variables['attributes']['class'][] = 'page-user-' . $path_args[1];
}
if (isset($path_args[0]) && isset($path_args[1]) && isset($path_args[2]) &&
$variables['attributes']['class'][] = 'page-taxonomy-term-' . $path_args[2];
$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($path_args[2]);
if (!empty($term)) {
$vocabulary_id = $term->bundle();
$variables['attributes']['class'][] = 'page-vocabulary-' . Html::cleanCssIdentifier($vocabulary_id);
}
}
$view_id = \Drupal::routeMatch()->getParameter('view_id');
if ($view_id) {
$variables['attributes']['class'][] = 'page-view-' . Html::cleanCssIdentifier($view_id);
// SEO Information.
'http-equiv' => 'x-ua-compatible',
'content' => 'ie=edge',
$variables['page']['#attached']['html_head'][] = [$http_equiv, 'http-equiv'];

Ridhima Abrol
committed
* Implements hook_page_attachments_alter() for page templates.
function bootstrap_barrio_page_attachments_alter(&$page) {
'#type' => 'html_tag',
'#tag' => 'meta',
'name' => 'viewport',
'content' => 'width=device-width, initial-scale=1, shrink-to-fit=no',
$page['#attached']['html_head'][] = [$viewport, 'viewport'];
}
/**
* Implements hook_preprocess_HOOK() for page templates.
*/
function bootstrap_barrio_preprocess_page(&$variables) {
if (\Drupal::moduleHandler()->moduleExists('bootstrap_library')) {
$library = theme_get_setting('bootstrap_barrio_library');
switch ($library) {
$variables['#attached']['library'][] = 'bootstrap_library/bootstrap-cdn';
break;

Ridhima Abrol
committed
case 'production':
$variables['#attached']['library'][] = 'bootstrap_library/bootstrap';
break;

Ridhima Abrol
committed
case 'development':
$variables['#attached']['library'][] = 'bootstrap_library/bootstrap-dev';
break;

Ridhima Abrol
committed
$fonts = theme_get_setting('bootstrap_barrio_google_fonts');
if ($fonts) {
$variables['#attached']['library'][] = 'bootstrap_barrio/' . $fonts;
}
$icons = theme_get_setting('bootstrap_barrio_bootstrap_icons');
if ($icons) {
$variables['#attached']['library'][] = 'bootstrap_barrio/bootstrap-icons';
$icons = theme_get_setting('bootstrap_barrio_icons');
if ($icons) {
$variables['#attached']['library'][] = 'bootstrap_barrio/' . $icons;
}
$system_messages = theme_get_setting('bootstrap_barrio_system_messages');
if ($system_messages) {
$variables['#attached']['library'][] = 'bootstrap_barrio/' . $system_messages;
}
$content_width = 'col';
$sidebar_first_width = 'col-md-' . theme_get_setting('bootstrap_barrio_sidebar_first_width');
$sidebar_second_width = 'col-md-' . theme_get_setting('bootstrap_barrio_sidebar_second_width');
// Define default classes for containers.
$variables['navbar_top_attributes'] = [

Ridhima Abrol
committed
'class' => ['navbar'],
'id' => ['navbar-top'],
];
$variables['navbar_attributes'] = [

Ridhima Abrol
committed
'class' => ['navbar'],
'id' => ['navbar-main'],
];
$variables['content_attributes'] = [

Ridhima Abrol
committed
'class' => ['main-content', $content_width],
'id' => ['content'],
'role' => ['main'],
];
$variables['sidebar_first_attributes'] = [
'class' => ['sidebar_first', 'sidebar', $sidebar_first_width],

Ridhima Abrol
committed
'id' => ['sidebar_first'],
];
$variables['sidebar_second_attributes'] = [
'class' => ['sidebar_second', 'sidebar', $sidebar_second_width],

Ridhima Abrol
committed
'id' => ['sidebar_second'],

Ridhima Abrol
committed
// Get custom Navbar classes from config and add them to Navbars.
if (theme_get_setting('bootstrap_barrio_navbar_top_class') !== NULL) {
$variables['navbar_top_attributes']['class'][] = theme_get_setting('bootstrap_barrio_navbar_top_class');
}
if (theme_get_setting('bootstrap_barrio_navbar_class') !== NULL) {
$variables['navbar_attributes']['class'][] = theme_get_setting('bootstrap_barrio_navbar_class');
}
$affix_navbar_top = theme_get_setting('bootstrap_barrio_navbar_top_affix');
$affix_navbar = theme_get_setting('bootstrap_barrio_navbar_affix');
$affix_sidebar_first = theme_get_setting('bootstrap_barrio_sidebar_first_affix');
$affix_sidebar_second = theme_get_setting('bootstrap_barrio_sidebar_second_affix');
if ($affix_navbar_top || $affix_navbar || $affix_sidebar_first || $affix_sidebar_second) {
$variables['#attached']['library'][] = 'bootstrap_barrio/affix';
if ($affix_navbar_top) {
$variables['navbar_top_attributes']['data-toggle'] = 'affix';
}
if ($affix_navbar) {
$variables['navbar_attributes']['data-toggle'] = 'affix';
}
if ($affix_sidebar_first) {
$variables['sidebar_first_attributes']['data-toggle'] = 'affix';
}
if ($affix_sidebar_second) {
$variables['sidebar_second_attributes']['data-toggle'] = 'affix';
// Calculate widths.
if (theme_get_setting('bootstrap_barrio_content_offset')) {
$variables['content_attributes']['class'][] = 'offset-md-' . theme_get_setting('bootstrap_barrio_content_offset');
}
if (theme_get_setting('bootstrap_barrio_sidebar_first_offset')) {
$variables['sidebar_first_attributes']['class'][] = 'offset-md-' . theme_get_setting('bootstrap_barrio_sidebar_first_offset');
}
if (theme_get_setting('bootstrap_barrio_sidebar_second_offset')) {
$variables['sidebar_second_attributes']['class'][] = 'offset-md-' . theme_get_setting('bootstrap_barrio_sidebar_second_offset');
// Define column layout classes.
switch (theme_get_setting('bootstrap_barrio_sidebar_position')) {

Ridhima Abrol
committed
case 'left':
$variables['sidebar_first_attributes']['class'][] = 'order-first';
$variables['content_attributes']['class'][] = 'order-last';
break;
case 'both':
$variables['sidebar_first_attributes']['class'][] = 'order-first';
$variables['sidebar_second_attributes']['class'][] = 'order-last';
break;
case 'right':
$variables['content_attributes']['class'][] = 'order-first';
$variables['sidebar_second_attributes']['class'][] = 'order-last';
break;
// Define navigation position.
$variables['navbar_top_attributes']['class'][] = theme_get_setting('bootstrap_barrio_navbar_top_position');
$variables['navbar_attributes']['class'][] = theme_get_setting('bootstrap_barrio_navbar_position');
// Define navigation color scheme.
$variables['navbar_top_attributes']['class'][] = theme_get_setting('bootstrap_barrio_navbar_top_color');
$variables['navbar_attributes']['class'][] = theme_get_setting('bootstrap_barrio_navbar_color');
// Define navigation background classes.
$variables['navbar_top_attributes']['class'][] = theme_get_setting('bootstrap_barrio_navbar_top_background');
$variables['navbar_attributes']['class'][] = theme_get_setting('bootstrap_barrio_navbar_background');
// Define navigation toggle size.
switch (theme_get_setting('bootstrap_barrio_navbar_toggle')) {
case 'navbar-toggleable-lg':
$variables['navbar_attributes']['class'][] = 'navbar-expand-lg';
break;

Ridhima Abrol
committed
case 'navbar-toggleable-md':
$variables['navbar_attributes']['class'][] = 'navbar-expand-md';
break;

Ridhima Abrol
committed
case 'navbar-toggleable-sm':
$variables['navbar_attributes']['class'][] = 'navbar-expand-sm';
break;

Ridhima Abrol
committed
case 'navbar-toggleable-xs':
$variables['navbar_attributes']['class'][] = 'navbar-expand-xs';
break;

Ridhima Abrol
committed
default:
$variables['navbar_attributes']['class'][] = 'navbar-expand-md';
break;
if (theme_get_setting('bootstrap_barrio_sidebar_collapse')) {

Ridhima Abrol
committed
$variables['content_attributes']['class'][] = 'sidebar-offcanvas';
$variables['sidebar_collapse'] = TRUE;
$variables['#attached']['library'][] = 'bootstrap_barrio/sidebar_collapse';
}
// Declare region attributes.
$variables['navbar_top_attributes'] = new Attribute($variables['navbar_top_attributes']);
$variables['navbar_attributes'] = new Attribute($variables['navbar_attributes']);
$variables['content_attributes'] = new Attribute($variables['content_attributes']);
$variables['sidebar_first_attributes'] = new Attribute($variables['sidebar_first_attributes']);
$variables['sidebar_second_attributes'] = new Attribute($variables['sidebar_second_attributes']);
// Declare container layout.
$variables['container_navbar'] = theme_get_setting('bootstrap_barrio_navbar_container');
$variables['container'] = theme_get_setting('bootstrap_barrio_fluid_container') ? 'container-fluid' : 'container';
}
/**
* Implements hook_preprocess_HOOK() for page templates.
*/
function bootstrap_barrio_preprocess_page_title(&$variables) {
// Since the title and the shortcut link are both block level elements,
// positioning them next to each other is much simpler with a wrapper div.
if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
// Add a wrapper div using the title_prefix and title_suffix render
// elements.
$variables['title_prefix']['shortcut_wrapper'] = [
'#markup' => '<div class="shortcut-wrapper clearfix">',
'#weight' => 100,
];
$variables['title_suffix']['shortcut_wrapper'] = [
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
// Make sure the shortcut link is the first item in title_suffix.
$variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
}
}
/**
* Implements hook_preprocess_HOOK() for maintenance-page.html.twig.
*/
function bootstrap_barrio_preprocess_maintenance_page(&$variables) {
// By default, site_name is set to Drupal if no db connection is available
// or during site installation. Setting site_name to an empty string makes
// the site and update pages look cleaner.
// @see template_preprocess_maintenance_page
if (!$variables['db_is_active']) {
$variables['site_name'] = '';
}
// Bootstrap Barrio has custom styling for the maintenance page.
$variables['#attached']['library'][] = 'bootstrap_barrio/maintenance_page';
}
/**
* Implements hook_preprocess_HOOK() for node.html.twig.
*/
function bootstrap_barrio_preprocess_node(&$variables) {
// Remove the "Add new comment" link on teasers or when the comment form is
// displayed on the page.
if ($variables['teaser'] || !empty($variables['content']['comments']['comment_form'])) {
unset($variables['content']['links']['comment']['#links']['comment-add']);
}
}
/**
* Implements hook_preprocess_HOOK() for region.html.twig.
*/
function bootstrap_barrio_preprocess_region(&$variables) {
'content',
'primary_menu',
'header',
'sidebar_first',
'sidebar_second',
];
if (theme_get_setting('bootstrap_barrio_region_class_' . $variables['elements']['#region']) !== NULL) {
$variables['attributes']['class'][] = theme_get_setting('bootstrap_barrio_region_class_' . $variables['elements']['#region']);
}
elseif (!in_array($variables['elements']['#region'], $nowrap)) {
$variables['attributes']['class'][] = 'row';
/**
* Implements hook_preprocess_HOOK() for block.html.twig.
*/
function bootstrap_barrio_preprocess_block(&$variables) {
if ($variables['base_plugin_id'] == 'system_menu_block' && isset($variables['attributes']['id'])) {

Alberto Siles
committed
$variables['content']['#attributes']['block'] = $variables['attributes']['id'];
}
// Add a clearfix class to system branding blocks.
if ($variables['plugin_id'] == 'system_branding_block') {
$variables['attributes']['class'][] = 'clearfix';
}
}
/**
* Implements hook_preprocess_HOOK() for form elements.
*/
function bootstrap_barrio_preprocess_form_element(&$variables) {
if (isset($variables['label']['#title'])) {

Ridhima Abrol
committed
if (is_object($variables['label']['#title']) && !$variables['label']['#title'] instanceof MarkupInterface) {
$variables['input_title'] = NULL;
}

Ridhima Abrol
committed
elseif (is_object($variables['label']['#title'])) {
$variables['input_title'] = $variables['label']['#title'];
}
else {
$variables['input_title'] = $variables['label']['#title'];
}
if (isset($variables['element']['#attributes'])) {
$variables['input_attributes'] = new Attribute($variables['element']['#attributes']);
}
if (isset($variables['type'])) {
switch ($variables['type']) {
case 'checkbox':
$variables['customtype'] = theme_get_setting('bootstrap_barrio_checkbox');
break;

Ridhima Abrol
committed
case 'radio':
$variables['customtype'] = theme_get_setting('bootstrap_barrio_radio');
break;

Ridhima Abrol
committed
default:
break;
}
}
}
/**
* Implements hook_preprocess_HOOK() for form-element-label.html.twig.
*/
function bootstrap_barrio_preprocess_form_element_label(&$variables) {
$element = $variables['element'];
}
/**
* Implements hook_preprocess_HOOK() for select.html.twig.
*/
function bootstrap_barrio_preprocess_select(&$variables) {
$variables['customtype'] = theme_get_setting('bootstrap_barrio_select');
}
/**
* Implements hook_preprocess_HOOK() for file-managed-file.html.twig.
*/
function bootstrap_barrio_preprocess_file_managed_file(&$variables) {
$variables['customtype'] = theme_get_setting('bootstrap_barrio_file');
/**
* Implements hook_preprocess_HOOK() for menu.html.twig.
*/
function bootstrap_barrio_preprocess_menu(&$variables) {
$variables['attributes']['class'][] = 'clearfix';
}

Ridhima Abrol
committed
/**
* Implements hook_preprocess_HOOK() for menu-local-task.html.twig.
*/
function bootstrap_barrio_preprocess_menu_local_task(&$variables) {
$link = $variables['element']['#link'];
$url = $link['url'];
$options = $url->getOptions();
$url->setOptions($options + $link['localized_options']);
$variables['item'] = Link::fromTextAndUrl($link['title'], $url);

Luke Stewart
committed
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function bootstrap_barrio_theme_suggestions_menu_alter(array &$suggestions, array $variables) {
// Taken from http://kristiankaa.dk/article/drupal8-region-specific-menu-theme-hook-suggestion
// bootstrap_barrio_preprocess_block(&$variables)
if (isset($variables['attributes']['block'])) {

Martin Postma
committed
$hook = str_replace(['block-', '-'], ['', '_'], $variables['attributes']['block']);

Luke Stewart
committed
$suggestions[] = $variables['theme_hook_original'] . '__' . $hook;
}
}
/**
* Implements hook_preprocess_HOOK() for menu-local-action.html.twig.
*/
function bootstrap_barrio_preprocess_menu_local_action(&$variables) {
$link = $variables['element']['#link'];
$link += [
'localized_options' => [],
];
$link['localized_options']['attributes']['class'][] = 'btn';
$link['localized_options']['attributes']['class'][] = 'btn-secondary';
$link['localized_options']['set_active_class'] = TRUE;
'#type' => 'link',
'#title' => $link['title'],
'#options' => $link['localized_options'],
'#url' => $link['url'],
/**
* Implements template_preprocess_table()
*/
function bootstrap_barrio_preprocess_table(&$variables) {
$variables['table_class'] = theme_get_setting('bootstrap_barrio_table_style');
$variables['hover'] = theme_get_setting('bootstrap_barrio_table_hover');
$variables['thead_class'] = theme_get_setting('bootstrap_barrio_table_head');
}
/**
* Implements template_preprocess_views_view_table()
*/
function bootstrap_barrio_preprocess_views_view_table(&$variables) {
$variables['table_class'] = theme_get_setting('bootstrap_barrio_table_style');
$variables['hover'] = theme_get_setting('bootstrap_barrio_table_hover');
$variables['thead_class'] = theme_get_setting('bootstrap_barrio_table_head');
}
/**
* Implements hook_theme_suggestions_HOOK_alter() for region templates.
*/
function bootstrap_barrio_theme_suggestions_region_alter(array &$suggestions, array $variables) {
$nowrap = [
'breadcrumb',
'sidebar_first',
'sidebar_second',
];

Ridhima Abrol
committed
if (theme_get_setting('bootstrap_barrio_region_clean_' . $variables['elements']['#region']) !== NULL) {
$region_clean = theme_get_setting('bootstrap_barrio_region_clean_' . $variables['elements']['#region']);
}
else {
$region_clean = in_array($variables['elements']['#region'], $nowrap);
}

Ridhima Abrol
committed
if ($region_clean) {
$suggestions[] = 'region__nowrap';
}
}

git
committed
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function bootstrap_barrio_theme_suggestions_user_alter(array &$suggestions, array $variables, $hook) {
// Define the view mode.
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$user_id = \Drupal::service('current_user')->id();
$suggestions[] = 'user__' . $sanitized_view_mode;
$suggestions[] = 'user__' . $user_id;
$suggestions[] = 'user__' . $user_id . '__' . $sanitized_view_mode;
return $suggestions;
}

Ridhima Abrol
committed
* Implements hook_theme_suggestions_HOOK_alter() for page template.

Denis K****
committed
function bootstrap_barrio_theme_suggestions_page_alter(array &$suggestions, array $variables) {
// Add a template suggestions for node type.
/** @var \Drupal\node\NodeInterface $node */
if ($node = \Drupal::routeMatch()->getParameter('node')) {
if (is_numeric($node)) {
$node = Node::load($node);
}
$suggestions[] = 'page__node__' . $node->bundle();
}
}
* Implements hook_theme_HOOK_form_alter() for node add/edit.
*/
function bootstrap_barrio_form_node_form_alter(&$form, FormStateInterface $form_state) {
$form['#theme'] = ['node_edit_form'];
}
/**
* Implements hook_theme_suggestions_HOOK_alter() for links templates.
*/
function bootstrap_barrio_theme_suggestions_links_alter(array &$suggestions, array $variables) {
// ToDo get from core a variable to flag inline links.
if (isset($variables['attributes']['class'])) {

Martin Postma
committed
if (in_array('inline', $variables['attributes']['class'])) {
$suggestions[] = 'links__inline';
}
/**
* Implements hook_theme_suggestions_HOOK_alter() for status messages templates.
*/
function bootstrap_barrio_theme_suggestions_status_messages_alter(array &$suggestions, array $variables) {
switch (theme_get_setting('bootstrap_barrio_messages_widget')) {
case 'toasts':
$suggestions[] = 'status_messages__toasts';
break;

Ridhima Abrol
committed
case 'alerts':
$suggestions[] = 'status_messages__alerts';
break;
/**
* Implements hook_preprocess_HOOK() for status_messages.
*/
function bootstrap_barrio_preprocess_status_messages(&$variables) {
$variables['title_ids'] = [];
foreach ($variables['message_list'] as $message_type => $messages) {
$variables['title_ids'][$message_type] = Html::getUniqueId("message-$message_type-title");
}
}
/**
* Implements hook_theme_suggestions_HOOK_alter() for form templates.
*/
function bootstrap_barrio_theme_suggestions_form_alter(array &$suggestions, array $variables) {
if ($variables['element']['#form_id'] == 'search_block_form') {
$suggestions[] = 'form__search_block_form';
}
if ($variables['element']['#form_id'] == 'node_form') {
$suggestions[] = 'node_edit_form';
}
}
/**
* Implements hook_theme_suggestions_HOOK_alter() for form templates.
*/
function bootstrap_barrio_theme_suggestions_input_alter(array &$suggestions, array $variables) {
if ($variables['element']['#type'] == 'submit' && theme_get_setting('bootstrap_barrio_button')) {
$suggestions[] = 'input__submit_button';
}
}
/**
* Implements hook_form_alter() to add classes to the search form.

Ridhima Abrol
committed
*/
/*
* function bootstrap_barrio_form_alter(
* &$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
* if (in_array($form_id, ['search_block_form', 'search_form'])) {
* $key = ($form_id == 'search_block_form') ? 'actions' : 'basic';
* if (!isset($form[$key]['submit']['#attributes'])) {
* $form[$key]['submit']['#attributes'] = new Attribute();
* }

Ridhima Abrol
committed
* $outline = theme_get_setting('bootstrap_barrio_button_outline') ?
* 'btn-outline-primary' : 'btn-primary';
* If use the $outline variable, HTML crashes. Even if use the value directly

Ridhima Abrol
committed
* $form[$key]['submit']['#attributes']->addClass(
* ['btn', 'btn-primary', 'btn-sm']);

Ridhima Abrol
committed
* }

Ridhima Abrol
committed
* Implements hook_preprocess_input() for adding classes to inputs.
*/
function bootstrap_barrio_preprocess_input(&$variables) {

Alberto Siles
committed
if (isset($variables['attributes']['class'])) {
if (is_object($variables['attributes']['class'])) {

Ridhima Abrol
committed
if (in_array('error', $variables['attributes']['class']->value())) {

Alberto Siles
committed
$variables['attributes']['class']->addClass('is-invalid');
}

Alberto Siles
committed
elseif (is_array($variables['attributes']['class'])) {

Ridhima Abrol
committed
if (in_array('error', $variables['attributes']['class'])) {

Alberto Siles
committed
$variables['attributes']['class'][] = 'is-invalid';
}
if ($variables['element']['#type'] == 'submit') {
$button_size = theme_get_setting('bootstrap_barrio_button_size');

Ridhima Abrol
committed
$button_types = [
'btn-primary',
'btn-secondary',
'btn-success',
'btn-warning',
'btn-danger',
'btn-link',
];

Alex Skrypnyk
committed
$button_sizes = ['btn-sm', 'btn-lg'];
$button_is_outline = theme_get_setting('bootstrap_barrio_button_outline');
\Drupal::logger('bootstrap_barrio')->notice(implode($variables['attributes']['class']->value()));

Alex Skrypnyk
committed
if (!in_array('btn', $variables['attributes']['class']->value())) {
$variables['attributes']['class']->addClass('btn');
}
if (empty(array_intersect($button_types, $variables['attributes']['class']->value()))) {
$variables['attributes']['class']->addClass('btn-outline-primary');
}
else {
$variables['attributes']['class']->addClass('btn-primary');
}
}

Alex Skrypnyk
committed
if ($button_size && empty(array_intersect($button_sizes, $variables['attributes']['class']->value()))) {
$variables['attributes']['class']->addClass($button_size);
}
}
else {

Alex Skrypnyk
committed
if (!in_array('btn', $variables['attributes']['class'])) {
$variables['attributes']['class'][] = 'btn';
if (empty(array_intersect($button_types, $variables['attributes']['class']))) {
if ($button_is_outline) {
$variables['attributes']['class'][] = 'btn-outline-primary';
}
else {
$variables['attributes']['class'][] = 'btn-primary';
}

Alex Skrypnyk
committed
if ($button_size && empty(array_intersect($button_sizes, $variables['attributes']['class']))) {
$variables['attributes']['class'][] = $button_size;
}

Alex Skrypnyk
committed
$variables['attributes'] = new Attribute($variables['attributes']);
$variables['safe_value_label'] = Xss::filter($variables['attributes']['value']);